Files
SpacetimeDB/crates
Jeffrey Dallatezza 33430cbe5c Dont use sentinel ids for system tables. (#3209)
# Description of Changes

This simplifies system table bootstrapping logic by removing
auto-incremented ids for indexes, constraints, and sequences in system
tables. By defining them all up front, we avoid the need for
`reset_system_table_schemas`, and make it easier to add new things to
system tables.

This change should not change the initial system table rows written
during bootstrapping, and the `load_1_2_*` tests in `relational_db.rs`
should verify that by loading data written by a previous version with
and without a snapshot.

I also added some sequence-related changes. The sequence schema previous
included the `allocated` field, which tracked where to start generating
new values after a restart. This made some checks awkward, since the
'schema' was changing as rows were inserted. I moved this outside of the
`schema`, so those should no longer change unless something actually
changes the shape of the tables.

As part of that, I also changed where we begin generating on startup to
be `allocated` instead of `allocated + 1`. The code that generates
values always stopped early enough to allow the next restart to use
`allocated`, so we were just being overly defensive. We also had some
issues if sequences wrapped over, or if we had sequences with negative
increments. Those were supported by the schema, but didn't really work
with the generation/allocation code. That should have better testing
now.


# Expected complexity level and risk

2. The bootstrapped system tables should match, since we have tests with
older data. The changes to sequences include some more invariant
checking, which has some risk of causing problems if previous versions
wrote values that I didn't consider.

# Testing

This has existing tests covering bootstrapping and restoring from a
snapshot.
2025-09-08 14:45:44 +00:00
..
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-21 09:43:50 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00
2025-08-12 18:20:58 +00:00