Skip to content

core: Store system tables in commitlog#1535

Closed
kim wants to merge 1 commit intomasterfrom
kim/st-in-commitlog
Closed

core: Store system tables in commitlog#1535
kim wants to merge 1 commit intomasterfrom
kim/st-in-commitlog

Conversation

@kim
Copy link
Copy Markdown
Contributor

@kim kim commented Jul 23, 2024

Changes the bootstrap sequence, such that the initial system table
schemas and contents are stored in the commitlog.

Opening a database proceeds as follows:

  • If a snapshot exists, restore it and replay the history suffix
  • Otherwise:
    • Create the "seed tables" st_table and st_columns in-memory
    • Replay the history
      • Whenever a table in the reserved system table range is found,
        reset the system table schema and layout information in the
        page manager, so as to repair incomplete schema information.
    • If the history was empty:
      • Create the rest of the system tables (i.e. sans seed tables) in a
        transaction.
      • Commit and persist that transaction.

Alternatives Considered

The already brittle bootrapping process is now even more brittle. In particular
the various incantations of repair / rebuild routines is hard to follow and easy
to break.

It is also unfortunate that the commitlog will be non-empty in case the
initialization from the user-supplied module fails.

As an alternative, a snapshot could be taken right after the database was fully
initialized, incl. the module. Instead of hashes, this snapshot could contain
their preimages and be inlined into the commitlog.

Restoring a database from such a snapshot requires only the statically known
schemas of the seed tables and a single repair pass.

API and ABI breaking changes

It will not be possible to open a database from a commitlog created by an older
version, because bootstrapping the system tables will only occur if the history
is empty.

Expected complexity level and risk

5 - database bootstrap is highly fragile

Changes the bootstrap sequence, such that the initial system table
schemas and contents are stored in the commitlog.

Opening a database proceeds as follows:

- If a snapshot exists, restore it and replay the history suffix
- Otherwise:
  - Create the "seed tables" `st_table` and `st_columns` in-memory
  - Replay the history
    - Whenever a table in the reserved system table range is found,
      reset the system table schema and layout information in the
      page manager, so as to repair incomplete schema information.
  - If the history was empty:
    - Create the rest of the system tables (i.e. sans seed tables) in a
      transaction.
    - Commit and persist that transaction.
@kim kim added the abi-break A PR that makes an ABI breaking change label Jul 23, 2024
@kim kim requested review from cloutiertyler and gefjon July 23, 2024 10:41
@kim kim linked an issue Jul 23, 2024 that may be closed by this pull request
@kim kim requested a review from Shubham8287 July 23, 2024 10:43
Copy link
Copy Markdown
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not love this. Having reviewed it, I am now much more convinced by your inline snapshots proposal and am inclined to push that forward rather than this.

ignore_duplicate_insert_error(st_tables.insert(blob_store, &row))?;
}

//
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//

@bfops bfops added the release-any To be landed in any release window label Jul 29, 2024
@cloutiertyler cloutiertyler added release-1.0 and removed release-any To be landed in any release window release-rc1-nice-to-have labels Nov 22, 2024
@bfops bfops assigned kim Jan 6, 2025
@bfops bfops added the reassessing Taking a step back to reconsider the problem/scope label Mar 4, 2025
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 3, 2025

CLA assistant check
All committers have signed the CLA.

@cloutiertyler cloutiertyler added the close-stale-pr-create-issue Indicates that the PR is substantially out of date, and should become an issue to reimplement. label Apr 13, 2026
@clockwork-labs-bot
Copy link
Copy Markdown
Collaborator

Closing per the close-stale-pr-create-issue label. This work is now tracked in #4800 for reimplementation on a fresh branch.

Replacement issue: #4800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abi-break A PR that makes an ABI breaking change close-stale-pr-create-issue Indicates that the PR is substantially out of date, and should become an issue to reimplement. reassessing Taking a step back to reconsider the problem/scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bootstrap the system tables from the commitlog

6 participants