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

mito: Potential issue to recover truncated data #3104

Closed
evenyag opened this issue Jan 5, 2024 · 2 comments
Closed

mito: Potential issue to recover truncated data #3104

evenyag opened this issue Jan 5, 2024 · 2 comments
Labels
C-bug Category Bugs

Comments

@evenyag
Copy link
Contributor

evenyag commented Jan 5, 2024

What type of bug is this?

Incorrect result

What subsystems are affected?

Standalone mode, Datanode

Minimal reproduce step

Truncate a region and restart the process before obsoleting the truncated entry.

What did you expect to see?

Region is empty

What did you see instead?

Region contains truncated data

What operating system did you use?

All

Relevant log output and stack trace

NA
@evenyag
Copy link
Contributor Author

evenyag commented Jan 5, 2024

Now the region doesn't consider truncated entries during replay.

let flushed_entry_id = version.flushed_entry_id;
let version_control = Arc::new(VersionControl::new(version));
if !self.skip_wal_replay {
info!(
"Start replaying memtable at flushed_entry_id + 1 {} for region {}",
flushed_entry_id + 1,
region_id
);
replay_memtable(
wal,
&wal_options,
region_id,
flushed_entry_id,
&version_control,
)

It should skip entries <= truncated_entry_id. We might do this in replay_memtable().

@evenyag evenyag added the C-bug Category Bugs label Jan 5, 2024
@evenyag evenyag self-assigned this Jan 5, 2024
@evenyag
Copy link
Contributor Author

evenyag commented Mar 27, 2024

After checking how we recover the truncate action, I found that apply_truncate() updates the flushed entry id by the truncated entry id. Thus the region won't replay entries before the truncated entry id.

pub fn apply_truncate(&mut self, manifest_version: ManifestVersion, truncate: RegionTruncate) {
self.manifest_version = manifest_version;
self.flushed_entry_id = truncate.truncated_entry_id;
self.flushed_sequence = truncate.truncated_sequence;
self.truncated_entry_id = Some(truncate.truncated_entry_id);
self.files.clear();
}

@evenyag evenyag closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

No branches or pull requests

1 participant