Skip to content

Do not compare op_type in WithinPenultimateLevelOutputRange() - #12081

Closed
cbi42 wants to merge 1 commit into
meta:mainfrom
cbi42:compare-seq
Closed

cbi42 wants to merge 1 commit into
meta:mainfrom
cbi42:compare-seq

Conversation

@cbi42

@cbi42 cbi42 commented Nov 20, 2023

Copy link
Copy Markdown
Contributor

WithinPenultimateLevelOutputRange() is updated in #12063 to check internal key range. However, op_type of a key can change during compaction, e.g. MERGE -> PUT, which makes a key larger and becomes out of penultimate output range. This has caused stress test failures with error message "Unsafe to store Seq later than snapshot in the last level if per_key_placement is enabled". So update WithinPenultimateLevelOutputRange() to only check user key and sequence number.

Test plan:

  • This repro can produce the corruption within a few runs. Ran it a few times after the fix and did not see Corruption failure.
python3 ./tools/db_crashtest.py whitebox --test_tiered_storage --random_kill_odd=888887 --use_merge=1 --writepercent=100 --readpercent=0 --prefixpercent=0 --delpercent=0 --delrangepercent=0 --iterpercent=0 --write_buffer_size=419430 --column_families=1 --read_fault_one_in=0 --write_fault_one_in=0

@cbi42 cbi42 changed the title Do not check op_type in WithinPenultimateLevelOutputRange() Do not compare op_type in WithinPenultimateLevelOutputRange() Nov 20, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cbi42 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ajkr ajkr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unsafe to store Seq later than snapshot in the last level if per_key_placement is enabled

Do you know why it's unsafe?

@ajkr

ajkr commented Nov 21, 2023

Copy link
Copy Markdown
Contributor

Unsafe to store Seq later than snapshot in the last level if per_key_placement is enabled

Do you know why it's unsafe?

https://github.com/facebook/rocksdb/pull/9964/files#r1024745198 - pretty non-obvious

@cbi42

cbi42 commented Nov 21, 2023

Copy link
Copy Markdown
Contributor Author

Unsafe to store Seq later than snapshot in the last level if per_key_placement is enabled

Do you know why it's unsafe?

https://github.com/facebook/rocksdb/pull/9964/files#r1024745198 - pretty non-obvious

Thanks for digging this up, I did not remember it. It seems it could be safe now since we don't allow preclude_last_level_data_seconds to be dynamically changeable.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cbi42 merged this pull request in fb5c8c7.

Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
…#12081)

Summary:
`WithinPenultimateLevelOutputRange()` is updated in meta#12063 to check internal key range. However, op_type of a key can change during compaction, e.g. MERGE -> PUT, which makes a key larger and becomes out of penultimate output range. This has caused stress test failures with error message "Unsafe to store Seq later than snapshot in the last level if per_key_placement is enabled". So update `WithinPenultimateLevelOutputRange()` to only check user key and sequence number.

Pull Request resolved: meta#12081

Test Plan:
* This repro can produce the corruption within a few runs. Ran it a few times after the fix and did not see Corruption failure.
```
python3 ./tools/db_crashtest.py whitebox --test_tiered_storage --random_kill_odd=888887 --use_merge=1 --writepercent=100 --readpercent=0 --prefixpercent=0 --delpercent=0 --delrangepercent=0 --iterpercent=0 --write_buffer_size=419430 --column_families=1 --read_fault_one_in=0 --write_fault_one_in=0
```

Reviewed By: ajkr

Differential Revision: D51481202

Pulled By: cbi42

fbshipit-source-id: cad6b65099733e03071b496e752bbdb09cf4db82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants