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

fix panic when reusing a was-empty batch #267

Merged
merged 6 commits into from
Sep 8, 2022

Conversation

tabokie
Copy link
Member

@tabokie tabokie commented Sep 1, 2022

Close #266

An empty batch went through finish_populate but not drain (in memtable apply block). This will break internal state machine and panic.

Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
@tabokie tabokie requested a review from Connor1996 September 1, 2022 07:03
@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Base: 97.74% // Head: 97.67% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (5311860) compared to base (618eea7).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
- Coverage   97.74%   97.67%   -0.08%     
==========================================
  Files          30       30              
  Lines       10633    10655      +22     
==========================================
+ Hits        10393    10407      +14     
- Misses        240      248       +8     
Impacted Files Coverage Δ
src/engine.rs 97.92% <100.00%> (+0.02%) ⬆️
src/consistency.rs 91.11% <0.00%> (-2.23%) ⬇️
src/log_batch.rs 97.97% <0.00%> (-0.41%) ⬇️
src/codec.rs 98.34% <0.00%> (-0.34%) ⬇️
src/purge.rs 97.22% <0.00%> (-0.28%) ⬇️
src/memtable.rs 99.16% <0.00%> (-0.06%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tabokie
Copy link
Member Author

tabokie commented Sep 6, 2022

/cc @LykxSassinator

Copy link
Contributor

@LykxSassinator LykxSassinator left a comment

Choose a reason for hiding this comment

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

Rest LGTM

src/engine.rs Outdated
let start = Instant::now();
let len = log_batch.finish_populate(self.cfg.batch_compression_threshold.0 as usize)?;
debug_assert!(!log_batch.is_empty());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do it before finish_populate or remove it. The first validation log_batch.is_empty() has guaranteed that log_batch.is_empty() == false.

src/engine.rs Outdated Show resolved Hide resolved
Signed-off-by: Xinye Tao <xy.tao@outlook.com>
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@tabokie tabokie merged commit 087d36b into tikv:master Sep 8, 2022
@tabokie tabokie deleted the 220901-fix-empty-batch branch September 8, 2022 09:00
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.

Writing an empty batch causes panic
3 participants