|
|
@ -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
|
|
|
|
// 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.
|
|
|
|
// not RESET the WAL file.
|
|
|
|
walSzPre := mustFileSize(db.WALPath())
|
|
|
|
walSzPre := mustFileSize(db.WALPath())
|
|
|
|
hdrPre := mustGetWALHeader(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")
|
|
|
|
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()
|
|
|
|
blockingDB.Close()
|
|
|
|
if err := db.CheckpointWithTimeout(CheckpointTruncate, 250*time.Millisecond); err != nil {
|
|
|
|
if err := db.CheckpointWithTimeout(CheckpointTruncate, 250*time.Millisecond); err != nil {
|
|
|
|
t.Fatalf("failed to checkpoint database: %s", err.Error())
|
|
|
|
t.Fatalf("failed to checkpoint database: %s", err.Error())
|
|
|
|