1
0
Fork 0
master
Philip O'Toole 8 months ago
parent 202d502b08
commit 379cb4575e

@ -158,7 +158,7 @@ func Test_WALDatabaseCheckpoint_RestartTimeout(t *testing.T) {
}
// Get some information on the WAL file before the checkpoint. The goal here is
// to confirm that after a non-completing TRUNCATE checkpoint, a write does
// to confirm that after a non-completing RESTART checkpoint, a write does
// not RESET the WAL file.
walSzPre := mustFileSize(db.WALPath())
hdrPre := mustGetWALHeader(db.WALPath())
@ -233,6 +233,25 @@ func Test_WALDatabaseCheckpoint_TruncateTimeout(t *testing.T) {
t.Fatalf("wal file should be unchanged after checkpoint failure")
}
// Confirm that the next write to the WAL is appended to the WAL file, and doesn't
// overwrite the first page i.e. that the WAL is not reset.
hdrPre := mustGetWALHeader(db.WALPath())
_, err = db.ExecuteStringStmt(`INSERT INTO foo(name) VALUES("fiona")`)
if err != nil {
t.Fatalf("failed to execute INSERT on single node: %s", err.Error())
}
rows, err = db.QueryStringStmt(`SELECT COUNT(*) FROM foo`)
if err != nil {
t.Fatalf("failed to execute query on single node: %s", err.Error())
}
if exp, got := `[{"columns":["COUNT(*)"],"types":["integer"],"values":[[51]]}]`, asJSON(rows); exp != got {
t.Fatalf("expected %s, got %s", exp, got)
}
hdrPost := mustGetWALHeader(db.WALPath())
if !bytes.Equal(hdrPre, hdrPost) {
t.Fatalf("wal file header should be unchanged after post-failed-TRUNCATE checkpoint write")
}
blockingDB.Close()
if err := db.CheckpointWithTimeout(CheckpointTruncate, 250*time.Millisecond); err != nil {
t.Fatalf("failed to checkpoint database: %s", err.Error())

Loading…
Cancel
Save