Re-add schemaOnly parameter when applying raft log entries and ensure we reloadDB on catching up #4897
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's being changed:
Reverts #4882. Re-add the schema only check in the db.apply function and add a new atomic
dbAndRaftAligned
that is set to true once RAFT has caught up and re-applied log entries after a restart and we no longer need to use schema only.This is necessary because on restart RAFT will re-apply log entries from disk to update the in-memory representation. As our DB operations are not truly idempotent we want to use a
schemaOnly
parameter to avoid updating the DB and only update the in-memory schema representation.For example given the following order of operations (Operation -> In memory SchemaState | DBState)
If a node is to restart, it will replay the raft log entries (which are 1, 2 and 3 above) but not the data related operations as these are not handled by RAFT. On restarting a node the following sequence is happening
With this change when we are replaying log operation we avoid updating the DB until we have caught up and then reload the DB representation to ensure we have everything loading as is represented in the up-to-date schema.
Review checklist