Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Replay database prefix #527

Merged
merged 5 commits into from
Nov 15, 2023
Merged

core: Replay database prefix #527

merged 5 commits into from
Nov 15, 2023

Conversation

kim
Copy link
Contributor

@kim kim commented Nov 6, 2023

Description of Changes

When replaying the log, stop if a commit is encountered which cannot be decoded. As this implies a corrupted log, truncate the log to the known-good prefix.

Depends on #526

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

If the API is breaking, please state below what will break

Expected complexity level and risk

3 -- the risk of truncating the commit log wrongly is data loss.

@kim kim force-pushed the kim/truncate-log-in-replay branch 5 times, most recently from 5adb3bd to 8416436 Compare November 9, 2023 10:50
@kim kim changed the title [WIP] core: Replay database prefix core: Replay database prefix Nov 9, 2023
@kim kim added the release-0.8 label Nov 9, 2023
@kim kim marked this pull request as ready for review November 9, 2023 10:51
);
let total_segments = message_log.total_segments();

'replay: for (segment_offset, segment) in message_log.segments().enumerate() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I intend to reduce the rightward drift here and move the replay logic elsewhere.
I left it here for this patch to preserve the side-by-side diff for review.

Copy link
Contributor

@kulakowski kulakowski left a comment

Choose a reason for hiding this comment

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

lgtm pending Joshua's feedback.

crates/core/src/db/relational_db.rs Show resolved Hide resolved
kim added 5 commits November 13, 2023 14:20
If a commit cannot be decoded from the log, stop replaying and truncate
the log to the known-good prefix.
When rotating a segment, the max_offset got incremented, leading to a
gap of one between the segment's min offset and the offset of the first
commit (when viewed as a commit log).

This means that offset calculations for truncation or suffix iterators
were off by one.
@kim kim force-pushed the kim/truncate-log-in-replay branch from 0ecc5cc to fa0d2e5 Compare November 13, 2023 13:26
@kim kim merged commit 32035ad into master Nov 15, 2023
5 checks passed
@kim kim deleted the kim/truncate-log-in-replay branch November 15, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants