mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 09:04:19 +01:00
properly set last_checksum after recovering wal
We store `last_checksum` to do cumulative checksumming. After reading wal for recovery, we didn't set last checksum properly in case there were no frames so this cause us to not initialize last_checksum properly.
This commit is contained in:
@@ -734,6 +734,34 @@ fn test_wal_bad_frame() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_wal_dumb_no_frames() -> anyhow::Result<()> {
|
||||
maybe_setup_tracing();
|
||||
let _ = env_logger::try_init();
|
||||
let db_path = {
|
||||
let tmp_db = TempDatabase::new_empty(false);
|
||||
let conn = tmp_db.connect_limbo();
|
||||
conn.close()?;
|
||||
let db_path = tmp_db.path.clone();
|
||||
db_path
|
||||
};
|
||||
// Second connection must recover from the WAL file. Last checksum should be filled correctly.
|
||||
{
|
||||
let tmp_db = TempDatabase::new_with_existent(&db_path, false);
|
||||
let conn = tmp_db.connect_limbo();
|
||||
conn.execute("CREATE TABLE t0(x)")?;
|
||||
conn.close()?;
|
||||
}
|
||||
{
|
||||
let tmp_db = TempDatabase::new_with_existent(&db_path, false);
|
||||
let conn = tmp_db.connect_limbo();
|
||||
conn.execute("INSERT INTO t0(x) VALUES (1)")?;
|
||||
conn.close()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_query(tmp_db: &TempDatabase, conn: &Arc<Connection>, query: &str) -> anyhow::Result<()> {
|
||||
run_query_core(tmp_db, conn, query, None::<fn(&Row)>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user