-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
catalog: Deserialize audit log in background
This commit optimizes the startup process to deserialize the audit log in the background. Opening the durable catalog involves deserializing all updates, migrating them, and then storing them in memory. Later the in-memory catalog will take each update and generate a builtin table update and apply that update in-memory. Throughout the startup process audit logs are heavily special cased and only used to generate builtin table updates. Additionally, audit logs are by far the largest catalog collection and can take a long time to deserialize. This commit creates a new thread at the beginning of the startup process that deserializes all audit log updates. A handle for the thread is plumbed throughout startup and then joined only when we actually need the builtin table updates. By deserializing these updates in the background we can reduce the total time spent in startup. In order for this all to work, we have to disallow migrating audit log updates, because now the audit log updates skip over migrations. In practice this is OK, because the audit log has its own versioning scheme that allows us to add new audit log variants without a migration. The only thing we lose is the ability to re-write old audit logs. This speedup works only because other parts of startup take long enough to hide the time spent deserializing the audit log. As other parts of startup get faster, joining on the deserializing thread will get slower. Some additional optimizations we can make in the future are: - Remove the audit log from the catalog. - Make the catalog shard queryable and remove the need to generate builtin table updates. - Now that the audit log is truly append-only, we could lazily deserialize the audit log updates in order by ID (how to order them is something we'd need to figure out), and stop once we've found the latest audit log update that is already in the builtin table. In general that will usually be the first audit log update we deserialize, unless we crashed after committing a catalog transaction but before updating the builtin tables. Works towards resolving #MaterializeInc/database-issues/issues/8384
- Loading branch information
Showing
14 changed files
with
229 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.