{
  "schema_version": 1,
  "id": "sqlite-backup-retention",
  "status": "reproducible-research",
  "accessed_on": "2026-10-21",
  "contribution": "Synthesis and controlled reproduction: backup cleanup, source-read ownership, deferred BEGIN and WAL retention limits.",
  "corpus_comparison": {
    "existing": [
      "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/",
      "https://hesela.com/analyses/sqlite-wal-checkpoint-starvation/"
    ],
    "pending_prior_work": "https://github.com/hesela/hesela-seo/pull/2103",
    "new_scope": [
      "Post-finish and post-cancel source read lifetime",
      "BEGIN-only control with autocommit versus per-schema transaction state",
      "journal_size_limit=-1 versus 0",
      "Pinned upstream 3.54.1 replication and reader-only control"
    ]
  },
  "artifact_contract": {
    "raw": [
      "observations-system.json",
      "observations-upstream.json"
    ],
    "derived": "summary.json",
    "generator": "observe.py",
    "summarizer": "summarize.py",
    "tests": "test_observe.py",
    "data_origin": "Synthetic deterministic software fixtures",
    "wal_bytes": "Filesystem stat st_size; not allocated bytes or device writes",
    "checkpointed_frames": "Cumulative checkpoint progress within the current WAL cycle",
    "generation": "Synthetic version label; not time or an SQLite transaction identifier",
    "source_states": {
      "0": "SQLITE_TXN_NONE",
      "1": "SQLITE_TXN_READ",
      "2": "SQLITE_TXN_WRITE"
    },
    "scope": "Linux, ordered single-thread calls, WAL source, DELETE-initialized destination; no crash, concurrent calls or timing"
  },
  "sources": [
    {
      "id": "backup-api",
      "url": "https://sqlite.org/c3ref/backup_finish.html",
      "type": "official-api",
      "supports": [
        "DONE versus finish",
        "Source and destination handle restrictions",
        "External-writer restarts"
      ]
    },
    {
      "id": "backup-guide",
      "url": "https://sqlite.org/backup.html",
      "type": "official-guide",
      "supports": [
        "Incremental copying context"
      ]
    },
    {
      "id": "wal",
      "url": "https://sqlite.org/wal.html",
      "type": "official-design",
      "supports": [
        "Reader end marks",
        "Checkpoint and reuse constraints"
      ],
      "sections": [
        "2.2",
        "6"
      ]
    },
    {
      "id": "checkpoint",
      "url": "https://sqlite.org/c3ref/wal_checkpoint_v2.html",
      "type": "official-api",
      "supports": [
        "PASSIVE may leave work",
        "TRUNCATE and BUSY",
        "Counts include earlier checkpoint progress"
      ]
    },
    {
      "id": "isolation",
      "url": "https://sqlite.org/isolation.html",
      "type": "official-design",
      "supports": [
        "WAL snapshot visibility"
      ]
    },
    {
      "id": "journal-limit",
      "url": "https://sqlite.org/pragma.html#pragma_journal_size_limit",
      "type": "official-api",
      "supports": [
        "Retained journal/WAL file size setting, not an active-data quota"
      ]
    },
    {
      "id": "txn-state",
      "url": "https://sqlite.org/c3ref/txn_state.html",
      "type": "official-api",
      "supports": [
        "Per-schema read/write/none state"
      ]
    },
    {
      "id": "autocommit",
      "url": "https://sqlite.org/c3ref/get_autocommit.html",
      "type": "official-api",
      "supports": [
        "BEGIN disables autocommit; rollback re-enables it"
      ]
    },
    {
      "id": "upstream-download",
      "url": "https://sqlite.org/download.html",
      "type": "official-distribution",
      "supports": [
        "Published archive SHA3-256 and version at access"
      ]
    },
    {
      "id": "upstream-release",
      "url": "https://sqlite.org/releaselog/3_54_1.html",
      "type": "official-release",
      "supports": [
        "Source ID and sqlite3.c SHA3-256"
      ]
    },
    {
      "id": "rights",
      "url": "https://sqlite.org/copyright.html",
      "type": "official-rights-statement",
      "supports": [
        "SQLite deliverable code/documentation dedicated to public domain"
      ]
    }
  ],
  "upstream_build": {
    "version": "3.54.1",
    "url": "https://sqlite.org/2026/sqlite-amalgamation-3540100.zip",
    "archive_sha3_256": "92281c86e2957f9b9305890f9ac04204caa7b677cc868dc326d942689df28e30",
    "sqlite3_c_sha3_256": "e2b869d3003b33c942b7dd7063604fbc53553e1b66609570df39b9b7b558ee81",
    "source_id": "2026-10-16 14:45:20 555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76",
    "binary_sha256": "39375610878c710864f3d7f072c6c3ff05bd1842ca57ec915b20900b39f79d17",
    "compiler": "gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0",
    "command": "gcc -O2 -fPIC -shared -DSQLITE_THREADSAFE=1 -o libsqlite3-3.54.1.so sqlite-amalgamation-3540100/sqlite3.c -lpthread -ldl -lm",
    "reviewed_locators": [
      {
        "file": "sqlite3.c",
        "lines": [
          84747,
          84754
        ],
        "claim": "Step opens source read only when no transaction exists; marks it for closure"
      },
      {
        "file": "sqlite3.c",
        "lines": [
          84958,
          84968
        ],
        "claim": "Step closes only a read it opened"
      },
      {
        "file": "sqlite3.c",
        "lines": [
          84986,
          85035
        ],
        "claim": "Finish detaches object and rolls back outstanding destination transaction"
      },
      {
        "file": "sqlite3.c",
        "lines": [
          71174,
          71185
        ],
        "claim": "WAL truncation limit is bounded below by required frame extent"
      }
    ],
    "distribution": "Source archive and binary not committed; no global installation"
  },
  "limitations": [
    "Two differently configured builds on one host, not every SQLite version or platform",
    "Repetition is not a probability sample",
    "No physical-I/O, power-loss, concurrency-stress, timing or RTO/RPO measurement",
    "Pilots and native test reruns excluded from the retained 84 schedules",
    "Caller-owned transactions must not be confused with backup-owned resources"
  ],
  "publication": {
    "com": "Prepared extension to the existing backup and WAL-reader analyses",
    "dev": "Prepared evidence downloads and existing term revisions",
    "deployed": false
  }
}
