Slightly expand converage to file consistency check failure (#6800)
Summary: Current DBCompactionTest.ConsistencyFailTest checks DB fails after L0 inconsitency is found. Add slightly more coverage by introducing DBCompactionTest.ConsistencyFailTest2 which checks non-L0 files too. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6800 Test Plan: Run the new test. Reviewed By: riversand963 Differential Revision: D21384806 fbshipit-source-id: 36db7b657eed42115283fe2f6afa4c3a31a3b510
This commit is contained in:
parent
394f2bbd13
commit
c21c459771
@ -5024,10 +5024,11 @@ TEST_P(DBCompactionTestWithParam, FixFileIngestionCompactionDeadlock) {
|
|||||||
|
|
||||||
TEST_F(DBCompactionTest, ConsistencyFailTest) {
|
TEST_F(DBCompactionTest, ConsistencyFailTest) {
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
|
options.force_consistency_checks = true;
|
||||||
DestroyAndReopen(options);
|
DestroyAndReopen(options);
|
||||||
|
|
||||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
|
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
|
||||||
"VersionBuilder::CheckConsistency", [&](void* arg) {
|
"VersionBuilder::CheckConsistency0", [&](void* arg) {
|
||||||
auto p =
|
auto p =
|
||||||
reinterpret_cast<std::pair<FileMetaData**, FileMetaData**>*>(arg);
|
reinterpret_cast<std::pair<FileMetaData**, FileMetaData**>*>(arg);
|
||||||
// just swap the two FileMetaData so that we hit error
|
// just swap the two FileMetaData so that we hit error
|
||||||
@ -5046,6 +5047,48 @@ TEST_F(DBCompactionTest, ConsistencyFailTest) {
|
|||||||
|
|
||||||
ASSERT_NOK(Put("foo", "bar"));
|
ASSERT_NOK(Put("foo", "bar"));
|
||||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
|
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
|
||||||
|
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(DBCompactionTest, ConsistencyFailTest2) {
|
||||||
|
Options options = CurrentOptions();
|
||||||
|
options.force_consistency_checks = true;
|
||||||
|
options.target_file_size_base = 1000;
|
||||||
|
options.level0_file_num_compaction_trigger = 2;
|
||||||
|
BlockBasedTableOptions bbto;
|
||||||
|
bbto.block_size = 400; // small block size
|
||||||
|
options.table_factory.reset(new BlockBasedTableFactory(bbto));
|
||||||
|
DestroyAndReopen(options);
|
||||||
|
|
||||||
|
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
|
||||||
|
"VersionBuilder::CheckConsistency1", [&](void* arg) {
|
||||||
|
auto p =
|
||||||
|
reinterpret_cast<std::pair<FileMetaData**, FileMetaData**>*>(arg);
|
||||||
|
// just swap the two FileMetaData so that we hit error
|
||||||
|
// in CheckConsistency funcion
|
||||||
|
FileMetaData* temp = *(p->first);
|
||||||
|
*(p->first) = *(p->second);
|
||||||
|
*(p->second) = temp;
|
||||||
|
});
|
||||||
|
|
||||||
|
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
|
||||||
|
|
||||||
|
Random rnd(301);
|
||||||
|
std::string value = RandomString(&rnd, 1000);
|
||||||
|
|
||||||
|
ASSERT_OK(Put("foo1", value));
|
||||||
|
ASSERT_OK(Put("z", ""));
|
||||||
|
Flush();
|
||||||
|
ASSERT_OK(Put("foo2", value));
|
||||||
|
ASSERT_OK(Put("z", ""));
|
||||||
|
Flush();
|
||||||
|
|
||||||
|
// This probably returns non-OK, but we rely on the next Put()
|
||||||
|
// to determine the DB is frozen.
|
||||||
|
dbfull()->TEST_WaitForCompact();
|
||||||
|
ASSERT_NOK(Put("foo", "bar"));
|
||||||
|
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
|
||||||
|
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IngestOneKeyValue(DBImpl* db, const std::string& key,
|
void IngestOneKeyValue(DBImpl* db, const std::string& key,
|
||||||
|
@ -236,11 +236,11 @@ class VersionBuilder::Rep {
|
|||||||
|
|
||||||
auto f1 = level_files[i - 1];
|
auto f1 = level_files[i - 1];
|
||||||
auto f2 = level_files[i];
|
auto f2 = level_files[i];
|
||||||
#ifndef NDEBUG
|
|
||||||
auto pair = std::make_pair(&f1, &f2);
|
|
||||||
TEST_SYNC_POINT_CALLBACK("VersionBuilder::CheckConsistency", &pair);
|
|
||||||
#endif
|
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
auto pair = std::make_pair(&f1, &f2);
|
||||||
|
TEST_SYNC_POINT_CALLBACK("VersionBuilder::CheckConsistency0", &pair);
|
||||||
|
#endif
|
||||||
if (!level_zero_cmp_(f1, f2)) {
|
if (!level_zero_cmp_(f1, f2)) {
|
||||||
fprintf(stderr, "L0 files are not sorted properly");
|
fprintf(stderr, "L0 files are not sorted properly");
|
||||||
return Status::Corruption("L0 files are not sorted properly");
|
return Status::Corruption("L0 files are not sorted properly");
|
||||||
@ -279,6 +279,10 @@ class VersionBuilder::Rep {
|
|||||||
NumberToString(f2->fd.GetNumber()));
|
NumberToString(f2->fd.GetNumber()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
auto pair = std::make_pair(&f1, &f2);
|
||||||
|
TEST_SYNC_POINT_CALLBACK("VersionBuilder::CheckConsistency1", &pair);
|
||||||
|
#endif
|
||||||
if (!level_nonzero_cmp_(f1, f2)) {
|
if (!level_nonzero_cmp_(f1, f2)) {
|
||||||
fprintf(stderr, "L%d files are not sorted properly", level);
|
fprintf(stderr, "L%d files are not sorted properly", level);
|
||||||
return Status::Corruption("L" + NumberToString(level) +
|
return Status::Corruption("L" + NumberToString(level) +
|
||||||
|
Loading…
Reference in New Issue
Block a user