Fix msvc debug test failures (#6579)
Summary: 1. stats_history_test: one slice of stats history is 12526 Bytes, which is greater than original assumption. ![image](https://user-images.githubusercontent.com/17753898/77381970-5a611a80-6d3c-11ea-9d64-59d2e3c04f79.png) 2. table_test: in VerifyBlockAccessTrace function, release trace reader before delete trace file. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6579 Reviewed By: siying Differential Revision: D20767373 Pulled By: pdillinger fbshipit-source-id: e8647d665cbe83a3f5429639c6219b50c0912124
This commit is contained in:
parent
ef088f0e93
commit
df62cd5b35
@ -270,10 +270,10 @@ TEST_F(StatsHistoryTest, InMemoryStatsHistoryPurging) {
|
||||
}
|
||||
size_t stats_history_size = dbfull()->TEST_EstimateInMemoryStatsHistorySize();
|
||||
ASSERT_GE(slice_count, 9);
|
||||
ASSERT_GE(stats_history_size, 12000);
|
||||
// capping memory cost at 12000 bytes since one slice is around 10000~12000
|
||||
ASSERT_OK(dbfull()->SetDBOptions({{"stats_history_buffer_size", "12000"}}));
|
||||
ASSERT_EQ(12000, dbfull()->GetDBOptions().stats_history_buffer_size);
|
||||
ASSERT_GE(stats_history_size, 13000);
|
||||
// capping memory cost at 13000 bytes since one slice is around 10000~13000
|
||||
ASSERT_OK(dbfull()->SetDBOptions({{"stats_history_buffer_size", "13000"}}));
|
||||
ASSERT_EQ(13000, dbfull()->GetDBOptions().stats_history_buffer_size);
|
||||
// Wait for stats persist to finish
|
||||
for (; mock_time < 20; ++mock_time) {
|
||||
dbfull()->TEST_WaitForPersistStatsRun(
|
||||
@ -292,7 +292,7 @@ TEST_F(StatsHistoryTest, InMemoryStatsHistoryPurging) {
|
||||
dbfull()->TEST_EstimateInMemoryStatsHistorySize();
|
||||
// only one slice can fit under the new stats_history_buffer_size
|
||||
ASSERT_LT(slice_count, 2);
|
||||
ASSERT_TRUE(stats_history_size_reopen < 12000 &&
|
||||
ASSERT_TRUE(stats_history_size_reopen < 13000 &&
|
||||
stats_history_size_reopen > 0);
|
||||
ASSERT_TRUE(stats_count_reopen < stats_count && stats_count_reopen > 0);
|
||||
Close();
|
||||
|
@ -1120,51 +1120,53 @@ class BlockBasedTableTest
|
||||
const std::vector<BlockCacheTraceRecord>& expected_records) {
|
||||
c->block_cache_tracer_.EndTrace();
|
||||
|
||||
std::unique_ptr<TraceReader> trace_reader;
|
||||
Status s =
|
||||
NewFileTraceReader(env_, EnvOptions(), trace_file_path_, &trace_reader);
|
||||
EXPECT_OK(s);
|
||||
BlockCacheTraceReader reader(std::move(trace_reader));
|
||||
BlockCacheTraceHeader header;
|
||||
EXPECT_OK(reader.ReadHeader(&header));
|
||||
uint32_t index = 0;
|
||||
while (s.ok()) {
|
||||
BlockCacheTraceRecord access;
|
||||
s = reader.ReadAccess(&access);
|
||||
if (!s.ok()) {
|
||||
break;
|
||||
}
|
||||
ASSERT_LT(index, expected_records.size());
|
||||
EXPECT_NE("", access.block_key);
|
||||
EXPECT_EQ(access.block_type, expected_records[index].block_type);
|
||||
EXPECT_GT(access.block_size, 0);
|
||||
EXPECT_EQ(access.caller, expected_records[index].caller);
|
||||
EXPECT_EQ(access.no_insert, expected_records[index].no_insert);
|
||||
EXPECT_EQ(access.is_cache_hit, expected_records[index].is_cache_hit);
|
||||
// Get
|
||||
if (access.caller == TableReaderCaller::kUserGet) {
|
||||
EXPECT_EQ(access.referenced_key,
|
||||
expected_records[index].referenced_key);
|
||||
EXPECT_EQ(access.get_id, expected_records[index].get_id);
|
||||
EXPECT_EQ(access.get_from_user_specified_snapshot,
|
||||
expected_records[index].get_from_user_specified_snapshot);
|
||||
if (access.block_type == TraceType::kBlockTraceDataBlock) {
|
||||
EXPECT_GT(access.referenced_data_size, 0);
|
||||
EXPECT_GT(access.num_keys_in_block, 0);
|
||||
EXPECT_EQ(access.referenced_key_exist_in_block,
|
||||
expected_records[index].referenced_key_exist_in_block);
|
||||
{
|
||||
std::unique_ptr<TraceReader> trace_reader;
|
||||
Status s =
|
||||
NewFileTraceReader(env_, EnvOptions(), trace_file_path_, &trace_reader);
|
||||
EXPECT_OK(s);
|
||||
BlockCacheTraceReader reader(std::move(trace_reader));
|
||||
BlockCacheTraceHeader header;
|
||||
EXPECT_OK(reader.ReadHeader(&header));
|
||||
uint32_t index = 0;
|
||||
while (s.ok()) {
|
||||
BlockCacheTraceRecord access;
|
||||
s = reader.ReadAccess(&access);
|
||||
if (!s.ok()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
EXPECT_EQ(access.referenced_key, "");
|
||||
EXPECT_EQ(access.get_id, 0);
|
||||
EXPECT_TRUE(access.get_from_user_specified_snapshot == Boolean::kFalse);
|
||||
EXPECT_EQ(access.referenced_data_size, 0);
|
||||
EXPECT_EQ(access.num_keys_in_block, 0);
|
||||
EXPECT_TRUE(access.referenced_key_exist_in_block == Boolean::kFalse);
|
||||
ASSERT_LT(index, expected_records.size());
|
||||
EXPECT_NE("", access.block_key);
|
||||
EXPECT_EQ(access.block_type, expected_records[index].block_type);
|
||||
EXPECT_GT(access.block_size, 0);
|
||||
EXPECT_EQ(access.caller, expected_records[index].caller);
|
||||
EXPECT_EQ(access.no_insert, expected_records[index].no_insert);
|
||||
EXPECT_EQ(access.is_cache_hit, expected_records[index].is_cache_hit);
|
||||
// Get
|
||||
if (access.caller == TableReaderCaller::kUserGet) {
|
||||
EXPECT_EQ(access.referenced_key,
|
||||
expected_records[index].referenced_key);
|
||||
EXPECT_EQ(access.get_id, expected_records[index].get_id);
|
||||
EXPECT_EQ(access.get_from_user_specified_snapshot,
|
||||
expected_records[index].get_from_user_specified_snapshot);
|
||||
if (access.block_type == TraceType::kBlockTraceDataBlock) {
|
||||
EXPECT_GT(access.referenced_data_size, 0);
|
||||
EXPECT_GT(access.num_keys_in_block, 0);
|
||||
EXPECT_EQ(access.referenced_key_exist_in_block,
|
||||
expected_records[index].referenced_key_exist_in_block);
|
||||
}
|
||||
} else {
|
||||
EXPECT_EQ(access.referenced_key, "");
|
||||
EXPECT_EQ(access.get_id, 0);
|
||||
EXPECT_TRUE(access.get_from_user_specified_snapshot == Boolean::kFalse);
|
||||
EXPECT_EQ(access.referenced_data_size, 0);
|
||||
EXPECT_EQ(access.num_keys_in_block, 0);
|
||||
EXPECT_TRUE(access.referenced_key_exist_in_block == Boolean::kFalse);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
EXPECT_EQ(index, expected_records.size());
|
||||
}
|
||||
EXPECT_EQ(index, expected_records.size());
|
||||
EXPECT_OK(env_->DeleteFile(trace_file_path_));
|
||||
EXPECT_OK(env_->DeleteDir(test_path_));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user