{
"property": {
"canon_id": "wal_initialized_reflects_sync_outcome",
"statement": "The WAL initialized flag is set true only after a successful sync of the wal-header.",
"impl_source": {
"path": "core/storage/wal.rs",
"line": 3977,
"snippet": "prepare_wal_finish"
}
},
"scenario": {
"fault": {
"kind": "fail_nth",
"op": "Sync",
"nth": 1,
"error": "EIO",
"fired_count": 1
},
"op_trace": [
{
"seq": 1,
"op": "pwrite",
"detail": "db @0 len=4096",
"injected": false,
"result": "ok"
},
{
"seq": 2,
"op": "pwrite",
"detail": "db-wal @0 len=32",
"injected": false,
"result": "ok"
},
{
"seq": 3,
"op": "sync",
"detail": "db-wal",
"injected": true,
"result": "EIO"
}
],
"call_path": [
{ "label": "turso_core::connection::Connection::execute", "depth": 0, "role": "normal" },
{ "label": "turso_core::statement::Statement::_step", "depth": 1, "role": "normal" },
{ "label": "turso_core::vdbe::Program::normal_step", "depth": 2, "role": "normal" },
{ "label": "turso_core::vdbe::execute::op_halt", "depth": 3, "role": "normal" },
{ "label": "turso_core::vdbe::execute::halt", "depth": 4, "role": "normal" },
{ "label": "turso_core::vdbe::Program::commit_txn", "depth": 5, "role": "normal" },
{ "label": "turso_core::vdbe::Program::commit_txn_wal", "depth": 6, "role": "normal" },
{ "label": "turso_core::vdbe::Program::step_end_write_txn", "depth": 7, "role": "normal" },
{ "label": "turso_core::storage::pager::Pager::commit_tx", "depth": 8, "role": "normal" },
{ "label": "turso_core::storage::pager::Pager::commit_dirty_pages", "depth": 9, "role": "normal" },
{ "label": "turso_core::storage::pager::Pager::commit_dirty_pages_inner", "depth": 10, "role": "normal" },
{ "label": "turso_core::storage::wal::WalFile::prepare_wal_start", "depth": 11, "role": "normal" },
{ "label": "turso_core::storage::sqlite3_ondisk::begin_write_wal_header", "depth": 12, "role": "effect", "io_seq": 2 },
{ "label": "turso_core::storage::wal::WalFile::prepare_wal_finish", "depth": 11, "role": "fault", "io_seq": 3 }
],
"test_shape": [
{ "label": "PRAGMA journal_mode=WAL", "faulted": false },
{ "label": "CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, v INTEGER)", "faulted": true }
],
"seed": "cr_03_initialized_under_sync_eio/fail_nth(Sync,1,EIO)/pragma+create"
},
"verdict": {
"cr_id": "CR-03",
"expected_to_fail": {
"tag": "CR-03",
"reason": "turso (a) rolls back the partial header write on sync failure, or (b) exposes a public wal_initialized_atomic() accessor that distinguishes \"flag was set\" from \"file exists\"."
}
},
"relation": {
"kind": "state_eq",
"description": "StateEq under ProjectionMask { initialized }",
"compared": [
"initialized"
],
"ignored": [
"max_frame",
"max_frame_inflight",
"nbackfills",
"nbackfills_inflight",
"checkpoint_seq",
"on_disk_frame_count",
"durable_frame_count",
"on_disk_header_present",
"on_disk_header_durable"
]
},
"finding": {
"kind": "state_eq",
"expected": {
"label": "reference",
"fields": [
{
"field": "initialized",
"value": "false"
},
{
"field": "max_frame",
"value": "0"
},
{
"field": "max_frame_inflight",
"value": "0"
},
{
"field": "nbackfills",
"value": "0"
},
{
"field": "nbackfills_inflight",
"value": "0"
},
{
"field": "checkpoint_seq",
"value": "0"
},
{
"field": "on_disk_frame_count",
"value": "0"
},
{
"field": "durable_frame_count",
"value": "0"
},
{
"field": "on_disk_header_present",
"value": "false"
},
{
"field": "on_disk_header_durable",
"value": "false"
}
]
},
"actual": {
"label": "turso (observed)",
"fields": [
{
"field": "initialized",
"value": "true"
},
{
"field": "max_frame",
"value": "0"
},
{
"field": "max_frame_inflight",
"value": "0"
},
{
"field": "nbackfills",
"value": "0"
},
{
"field": "nbackfills_inflight",
"value": "0"
},
{
"field": "checkpoint_seq",
"value": "0"
},
{
"field": "on_disk_frame_count",
"value": "0"
},
{
"field": "durable_frame_count",
"value": "0"
},
{
"field": "on_disk_header_present",
"value": "true"
},
{
"field": "on_disk_header_durable",
"value": "true"
}
]
},
"divergence": [
{
"field": "initialized",
"expected": "false",
"actual": "true",
"provenance": "turso reports `initialized` from the *.db-wal file-existence proxy (a >=32-byte header on disk). The header write landed before the sync failed, so a non-durable header reads as present — turso cannot distinguish \"header bytes exist\" from \"header is durable\". The property requires a successful header sync before initialized is true."
}
]
}
}