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

In ParseInternalKey(), include corrupt key info in Status #7515

Closed
wants to merge 32 commits into from

Conversation

ramvadiv
Copy link
Contributor

@ramvadiv ramvadiv commented Oct 7, 2020

Fixes Issue #7497

When allow_data_in_errors db_options is set, log error key details in ParseInternalKey()

Have fixed most of the calls. Have few TODOs still pending - because have to make more deeper changes to pass in the allow_data_in_errors flag. Will do those in a separate PR later.

Tests:

  • make check
  • some of the existing tests that exercise the "internal key too small" condition are: dbformat_test, cuckoo_table_builder_test
  • some of the existing tests that exercise the corrupted key path are: corruption_test, merge_helper_test, compaction_iterator_test

Example of new status returns:

  • Key too small - Corrupted Key: Internal Key too small. Size=5
  • Corrupt key with allow_data_in_errors option set to false: Corrupted Key: '<redacted>' seq:3, type:3
  • Corrupt key with allow_data_in_errors option set to true: Corrupted Key: '61' seq:3, type:3

@ramvadiv ramvadiv marked this pull request as draft October 7, 2020 04:10
db/compaction/compaction_iterator.cc Outdated Show resolved Hide resolved
db/compaction/compaction_iterator.cc Outdated Show resolved Hide resolved
db/db_iter.cc Outdated Show resolved Hide resolved
db/dbformat.h Outdated Show resolved Hide resolved
db/external_sst_file_ingestion_job.cc Outdated Show resolved Hide resolved
db/merge_helper.cc Outdated Show resolved Hide resolved
db/merge_helper.cc Outdated Show resolved Hide resolved
db/repair.cc Outdated Show resolved Hide resolved
db/repair.cc Outdated Show resolved Hide resolved
db/compaction/compaction_iterator.cc Outdated Show resolved Hide resolved
@ramvadiv ramvadiv marked this pull request as ready for review October 8, 2020 21:55
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

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

Can you clarify what kind "gdb based inspection of error msgs"?

Should we at least add a unit test that directly covers the new parameter in ParseInternalKey()?

db/dbformat.h Outdated Show resolved Hide resolved
db/dbformat.h Outdated Show resolved Hide resolved
db/external_sst_file_ingestion_job.cc Outdated Show resolved Hide resolved
db/dbformat.h Outdated Show resolved Hide resolved
db/dbformat.h Outdated Show resolved Hide resolved
db/dbformat.h Outdated
if (n < kNumInternalBytes) {
return Status::Corruption("Internal Key too small");
std::string msg("Internal Key too small. ");
msg.append("Size=" + std::to_string(n) + ". ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Use StringUtil::ToString().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand this comment... Why?

db/merge_helper.h Outdated Show resolved Hide resolved
table/sst_file_dumper.cc Outdated Show resolved Hide resolved
table/table_test.cc Outdated Show resolved Hide resolved
tools/sst_dump_tool.cc Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

db/dbformat.h Outdated Show resolved Hide resolved
tools/ldb_test.py Outdated Show resolved Hide resolved
table/table_test.cc Outdated Show resolved Hide resolved
table/table_test.cc Outdated Show resolved Hide resolved
db/dbformat.cc Show resolved Hide resolved
…param, rename pikStatus to pik_status, revert back to previous output format in DebugString()
@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for adding the key data to so many places!

db/column_family.h Outdated Show resolved Hide resolved
db/db_iter.cc Outdated Show resolved Hide resolved
if (ParseInternalKey(iter->key(), &ikey) != Status::OK()) {
Status pik_status =
ParseInternalKey(iter->key(), &ikey, allow_data_in_errors);
if (!pik_status.ok()) {
// stop at corrupted key
if (assert_valid_internal_key_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[existing issue] It looks like this is initialized to false (

false /* internal key corruption is expected */,
). Is it a bug? In any case I think we should get rid of MergeHelper:: assert_valid_internal_key_ and also CompactionIterator::expect_valid_internal_key_ -- they seem error prone and not useful since we always want key corruptions to be reported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I will fix it in a separate PR.

db/merge_helper.h Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ramvadiv has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@facebook-github-bot
Copy link
Contributor

@ramvadiv merged this pull request in 9a690a7.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@ramvadiv merged this pull request in 9a690a7.

codingrhythm pushed a commit to SafetyCulture/rocksdb that referenced this pull request Mar 5, 2021
)

Summary:
Fixes Issue facebook#7497

When allow_data_in_errors db_options is set, log error key details in `ParseInternalKey()`

Have fixed most of the calls. Have few TODOs still pending - because have to make more deeper changes to pass in the allow_data_in_errors flag. Will do those in a separate PR later.

Tests:
- make check
- some of the existing tests that exercise the "internal key too small" condition are: dbformat_test, cuckoo_table_builder_test
- some of the existing tests that exercise the corrupted key path are: corruption_test, merge_helper_test, compaction_iterator_test

Example of new status returns:
- Key too small - `Corrupted Key: Internal Key too small. Size=5`
- Corrupt key with allow_data_in_errors option set to false: `Corrupted Key: '<redacted>' seq:3, type:3`
- Corrupt key with allow_data_in_errors option set to true: `Corrupted Key: '61' seq:3, type:3`

Pull Request resolved: facebook#7515

Reviewed By: ajkr

Differential Revision: D24240264

Pulled By: ramvadiv

fbshipit-source-id: bc48f5d4475ac19d7713e16df37505b31aac42e7
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.

None yet

5 participants