Skip to content

Keep BlockBuilder restart counter valid after ChangeOptions - #1342

Open
fyrsta7 wants to merge 1 commit into
google:mainfrom
fyrsta7:fix/block-builder-change-options
Open

fyrsta7 wants to merge 1 commit into
google:mainfrom
fyrsta7:fix/block-builder-change-options

Conversation

@fyrsta7

@fyrsta7 fyrsta7 commented Aug 4, 2026

Copy link
Copy Markdown

Summary

Fixes #1339 by keeping BlockBuilder's restart counter consistent when TableBuilder::ChangeOptions lowers block_restart_interval after entries have already been added.

Details

BlockBuilder::counter_ tracks how many entries have been emitted since the last restart point. If ChangeOptions installs a smaller restart interval while counter_ is already larger than that interval, the next Add can violate the builder's restart interval invariant.

This adds an OnOptionsChanged hook that clamps the counter to the current interval after the table builder updates its options. The new regression test builds a table block under interval 16, changes the interval to 2, adds another entry, finishes and reopens the table, and verifies that the entry can be found through an iterator.

Validation

I built and ran the repository's complete leveldb_tests binary. Of 212 tests, 211 passed and one compression-dependent test was skipped by the current build configuration; there were no failures.

I also ran the new regression test and the full TableTest.* group separately:

./build-pr-submodules/leveldb_tests \
  --gtest_filter=TableTest.ChangeOptionsLowerRestartInterval
./build-pr-submodules/leveldb_tests --gtest_filter=TableTest.*

git diff --check also passes.

@fyrsta7
fyrsta7 marked this pull request as ready for review August 8, 2026 15:42
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.

Bug: ChangeOptions lowers block_restart_interval without resetting BlockBuilder counter_ causing assertion failure

1 participant