-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read result row of pragma wal_checkpoint #1227
Comments
Please share a complete reproducible example, including which version of this library you are using. |
FWIW, I use this functionality heavily in rqlite, and I get non-zero values back for the scan. In other words, it seems to work fine for me.
Here is me running a hacked up unit test from rqlite: $ git diff
diff --git a/db/db.go b/db/db.go
index 6135ff90..75fc0b96 100644
--- a/db/db.go
+++ b/db/db.go
@@ -398,6 +398,7 @@ func (db *DB) CheckpointWithTimeout(mode CheckpointMode, dur time.Duration) (err
if err := db.rwDB.QueryRow(checkpointPRAGMAs[mode]).Scan(&ok, &nPages, &nMoved); err != nil {
return fmt.Errorf("error checkpointing WAL: %s", err.Error())
}
+ fmt.Println("checkpointed", nPages, "pages", nMoved, "moved")
stats.Add(numCheckpointedPages, int64(nPages))
stats.Add(numCheckpointedMoves, int64(nMoved))
if ok != 0 {
$ go test -run Test_DBSums
checkpointed 3 pages 3 moved
PASS
ok github.com/rqlite/rqlite/v8/db 0.048s
~/repos/rqlite/src/github.com/rqlite/rqlite/db (master)$ |
Nevermind, I could not reproduce in an isolated environment. My theory is that SQLite is doing an automatic checkpoint already once all the inflight transactions are finished. That is why the manual checkpoint returns all zeroes. |
Easy enough to validate, disable automatic checkpoints as rqlite does. |
The documentation https://www.sqlite.org/pragma.html#pragma_wal_checkpoint for pragma wal_checkpoint states that it returns a row with 3 columns
This is true from my experience when using the
sqlite3
commandI expect the same to work when using accessing a SQLite db from Go. However, that is not what I experience. When using this snippet:
The variables
blocked
,pagesWrittenToWAL
andpagesCheckpointed
. Always have 0 for their value, even when I know for a fact that the WAL file was checkpointed and some pages were checkpointed.The text was updated successfully, but these errors were encountered: