{"record":{"id":"349c73491b7805b7","repo":"clockworklabs/SpacetimeDB","slug":"delete-for-non-existent-row-when-replaying-transac","errorCode":null,"errorMessage":"Delete for non-existent row when replaying transaction","messagePattern":"Delete for non-existent row when replaying transaction","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/datastore/src/locking_tx_datastore/replay.rs","lineNumber":958,"sourceCode":"        }\n\n        Ok(())\n    }\n\n    fn replay_delete_by_rel(&mut self, table_id: TableId, row: &ProductValue) -> Result<()> {\n        // (1) Table dropped? Avoid an error and just ignore the row instead.\n        if self.replay_table_dropped.contains(&table_id) {\n            return Ok(());\n        }\n\n        // Get the table for mutation.\n        let (table, blob_store, _, page_pool) = self.get_table_and_blob_store_mut(table_id)?;\n\n        // Delete the row.\n        let row_ptr = table\n            .delete_equal_row(page_pool, blob_store, row)\n            .map_err(TableError::Bflatn)?\n            .ok_or_else(|| anyhow!(\"Delete for non-existent row when replaying transaction\"))?;\n\n        if table_id == ST_TABLE_ID {\n            let referenced_table_id = row\n                .elements\n                .get(StTableFields::TableId.col_idx())\n                .expect(\"`st_table` row should conform to `st_table` schema\")\n                .as_u32()\n                .expect(\"`st_table` row should conform to `st_table` schema\");\n            if self\n                .replay_table_updated\n                .remove(&TableId::from(*referenced_table_id))\n                .is_some()\n            {\n                // This delete is part of an update to an `st_table` row,\n                // i.e. earlier in this transaction we inserted a new version of the row.\n                // That means it's not a dropped table.\n            } else {\n                // A row was removed from `st_table`, so a table was dropped.","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/datastore/src/locking_tx_datastore/replay.rs#L940-L976","documentation":"Replaying a DELETE operation found no equal row in the rebuilt table: delete_equal_row returned None, meaning the commitlog claims a row existed to delete that the reconstructed committed state does not contain. Replay refuses to silently skip deletes, so it aborts and database open fails.","triggerScenarios":"A truncated or corrupted commitlog that lost the earlier insert of the deleted row; row-encoding (BSATN) changes between versions making row equality fail; replaying only a subset of a database's logs or mixing snapshots and logs from different points in time.","commonSituations":"Crash mid-commit followed by partial segment replay; copying a data directory while it is being written; upgrading versions that changed row layout without a migration.","solutions":["Restore from a consistent snapshot and replay only the logs taken after it","Ensure every node replays the complete commitlog from the same baseline","Use the version that encoded the rows to replay, then upgrade","Report suspected corruption with the preserved commitlog"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch the replay error at open; restore the latest consistent snapshot and replay only segments newer than it; if no snapshot covers the gap, mark the database unrecoverable rather than skipping the delete.","preventionTips":["Use durable commits so partially written transactions cannot appear in segments","Snapshot before and after large migrations","Avoid copying data directories of a running database"],"tags":["rust","spacetimedb","replay","delete","commitlog","corruption"],"backgroundTag":"wal-replay-failure","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}