mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 02:12:21 +00:00
Better comment
This commit is contained in:
parent
e6e71dc832
commit
1adef76cbd
@ -141,10 +141,11 @@ void CacheMetadata::doCleanup()
|
|||||||
|
|
||||||
auto key_metadata = it->second;
|
auto key_metadata = it->second;
|
||||||
auto key_lock = key_metadata->lock();
|
auto key_lock = key_metadata->lock();
|
||||||
/// As in lockKeyMetadata we extract key metadata from cache metadata
|
/// As in lockKeyMetadata we extract key metadata from cache metadata under
|
||||||
/// under CacheMetadataGuard::Lock, but take KeyGuard::Lock only after we
|
/// CacheMetadataGuard::Lock, but take KeyGuard::Lock only after we released
|
||||||
/// released cache CacheMetadataGuard::Lock, then we must to take into
|
/// cache CacheMetadataGuard::Lock (because CacheMetadataGuard::Lock must be lightweight).
|
||||||
/// account it here.
|
/// So it is possible that a key which was submitted to cleanup queue was afterwards added
|
||||||
|
/// to cache, so here we need to check this case.
|
||||||
if (key_metadata->getCleanupState(key_lock) == KeyMetadata::CleanupState::NOT_SUBMITTED)
|
if (key_metadata->getCleanupState(key_lock) == KeyMetadata::CleanupState::NOT_SUBMITTED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -189,36 +189,23 @@ TEST_F(FileCacheTest, get)
|
|||||||
std::cerr << "Step 1\n";
|
std::cerr << "Step 1\n";
|
||||||
|
|
||||||
auto cache = FileCache(cache_base_path, settings);
|
auto cache = FileCache(cache_base_path, settings);
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
cache.initialize();
|
cache.initialize();
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
auto key = cache.createKeyForPath("key1");
|
auto key = cache.createKeyForPath("key1");
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
auto holder = cache.getOrSet(key, 0, 10, {}); /// Add range [0, 9]
|
auto holder = cache.getOrSet(key, 0, 10, {}); /// Add range [0, 9]
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
assertEqual(holder, { Range(0, 9) }, { State::EMPTY });
|
assertEqual(holder, { Range(0, 9) }, { State::EMPTY });
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
download(holder->front());
|
download(holder->front());
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
assertEqual(holder, { Range(0, 9) }, { State::DOWNLOADED });
|
assertEqual(holder, { Range(0, 9) }, { State::DOWNLOADED });
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Current cache: [__________]
|
/// Current cache: [__________]
|
||||||
/// ^ ^
|
/// ^ ^
|
||||||
/// 0 9
|
/// 0 9
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
assertEqual(cache.getSnapshot(key), { Range(0, 9) });
|
assertEqual(cache.getSnapshot(key), { Range(0, 9) });
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
assertEqual(cache.dumpQueue(), { Range(0, 9) });
|
assertEqual(cache.dumpQueue(), { Range(0, 9) });
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
ASSERT_EQ(cache.getFileSegmentsNum(), 1);
|
ASSERT_EQ(cache.getFileSegmentsNum(), 1);
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
ASSERT_EQ(cache.getUsedCacheSize(), 10);
|
ASSERT_EQ(cache.getUsedCacheSize(), 10);
|
||||||
std::cerr << "Step 1\n";
|
|
||||||
|
|
||||||
std::cerr << "Step 2\n";
|
std::cerr << "Step 2\n";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user