Skip to content

Rollback safe system table additions - #6004

Merged
joshua-spacetime merged 1 commit into
masterfrom
jsdt/safe-system-table-additions
Oct 8, 2026
Merged

joshua-spacetime merged 1 commit into
masterfrom
jsdt/safe-system-table-additions

Conversation

@jsdt

@jsdt jsdt commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

TLDR: Write system table schema info to the commit log immediately for new databases.

Currently if we add new system tables, there is a specific case where trying to open a database with a previous version of spacetimedb can fail: if we create a new database with the added system table (and write something to that system table), we won't be able to replay the history for that database without a snapshot. In practice, this is an unlikely error case, since we always try to write a snapshot for a new database. Databases with a snapshot don't have a problem (because the new system table schema info is in the snapshot), and existing databases don't have a problem (because we create the new system tables in a transaction).

With this change, when we open a new database, we write all of the system table schema information to the commit log as the first transaction, so older versions will still be able to parse rows for those tables.

This also makes system-sequence initialization during migration match bootstrap initialization, and shifts the automatic snapshot trigger by one transaction to account for the new first transaction.

Expected complexity level and risk

Anything with system tables carries higher risk, but this has pretty good test coverage.

Testing

This updates some existing tests to make sure that the schema information is written to the commit log, and it adds a few additional tests in relational_db. The most important one is probably replay_from_commitlog_preserves_unknown_future_system_table, which simulates a replay with an unknown system table.

Rollback safety impact

n/a

Comment thread crates/datastore/src/locking_tx_datastore/mut_tx.rs
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
@joshua-spacetime
joshua-spacetime force-pushed the jsdt/safe-system-table-additions branch from ac0efba to 1ff854b Compare October 8, 2026 17:22
@joshua-spacetime
joshua-spacetime added this pull request to the merge queue Oct 8, 2026
Merged via the queue into master with commit 57bdad6 Oct 8, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants