Skip to content

Commit 14b1d9b

Browse files
authored
feature to move checkpoint callback if any frames is written (#2054)
Currently we report a checkpoint is finished only when `mxSafeFrame == mxFrame` in wal it is useful to have finish callback to be triggered in case any work moving frames was accomplished.
2 parents cdf9060 + adc75c5 commit 14b1d9b

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

libsql-ffi/Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ license.workspace = true
77
repository.workspace = true
88
description = "Native bindings to libSQL"
99
build = "build.rs"
10-
exclude = ["bundled/SQLite3MultipleCiphers/build", "bundled/SQLite3MultipleCiphers/test"]
10+
exclude = [
11+
"bundled/SQLite3MultipleCiphers/build",
12+
"bundled/SQLite3MultipleCiphers/test",
13+
]
1114

1215
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1316

@@ -37,11 +40,12 @@ sqlean-extension-math = []
3740
sqlean-extension-stats = []
3841
sqlean-extension-text = []
3942
sqlean-extensions = [
40-
"sqlean-extension-uuid",
41-
"sqlean-extension-crypto",
42-
"sqlean-extension-fuzzy",
43-
"sqlean-extension-math",
44-
"sqlean-extension-stats",
45-
"sqlean-extension-text"
43+
"sqlean-extension-uuid",
44+
"sqlean-extension-crypto",
45+
"sqlean-extension-fuzzy",
46+
"sqlean-extension-math",
47+
"sqlean-extension-stats",
48+
"sqlean-extension-text",
4649
]
4750
libsql-disable-checkpoint-downgrade = []
51+
libsql-checkpoint-callback-on-any-frame-written = []

libsql-ffi/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ pub fn build_bundled(out_dir: &str, out_path: &Path) {
276276
if cfg!(feature = "libsql-disable-checkpoint-downgrade") {
277277
cfg.flag("-DLIBSQL_DISABLE_CHECKPOINT_DOWNGRADE=1");
278278
}
279+
if cfg!(feature = "libsql-checkpoint-callback-on-any-frame-written") {
280+
cfg.flag("-DLIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN=1");
281+
}
279282

280283
if cfg!(feature = "bundled-sqlcipher") {
281284
cfg.flag("-DSQLITE_HAS_CODEC").flag("-DSQLITE_TEMP_STORE=2");

libsql-ffi/bundled/src/sqlite3.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67677,10 +67677,18 @@ static int walCheckpoint(
6767767677

6767867678
/* If work was actually accomplished... */
6767967679
if( rc==SQLITE_OK ){
67680+
#ifdef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
67681+
if (xCb) {
67682+
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
67683+
}
67684+
#endif
67685+
6768067686
if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
67687+
#ifndef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
6768167688
if (xCb) {
6768267689
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
6768367690
}
67691+
#endif
6768467692
if( rc==SQLITE_OK ){
6768567693
i64 szDb = pWal->hdr.nPage*(i64)szPage;
6768667694
testcase( IS_BIG_INT(szDb) );

libsql-sqlite3/src/wal.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,10 +2130,18 @@ static int walCheckpoint(
21302130

21312131
/* If work was actually accomplished... */
21322132
if( rc==SQLITE_OK ){
2133+
#ifdef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
2134+
if (xCb) {
2135+
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
2136+
}
2137+
#endif
2138+
21332139
if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
2140+
#ifndef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
21342141
if (xCb) {
21352142
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
21362143
}
2144+
#endif
21372145
if( rc==SQLITE_OK ){
21382146
i64 szDb = pWal->hdr.nPage*(i64)szPage;
21392147
testcase( IS_BIG_INT(szDb) );

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
profile = "default"
3-
channel = "1.81.0"
3+
channel = "1.82.0"

0 commit comments

Comments
 (0)