fix and add test for system.filesystem_cache_log

This commit is contained in:
KinderRiven 2022-04-30 23:38:57 +08:00
parent e1acacf831
commit 1145570c08
3 changed files with 40 additions and 2 deletions

View File

@ -72,10 +72,10 @@ void CachedReadBufferFromRemoteFS::appendFilesystemCacheLog(
elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_CACHE; elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_CACHE;
break; break;
case CachedReadBufferFromRemoteFS::ReadType::REMOTE_FS_READ_BYPASS_CACHE: case CachedReadBufferFromRemoteFS::ReadType::REMOTE_FS_READ_BYPASS_CACHE:
elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_FS_AND_DOWNLOADED_TO_CACHE; elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_FS_BYPASSING_CACHE;
break; break;
case CachedReadBufferFromRemoteFS::ReadType::REMOTE_FS_READ_AND_PUT_IN_CACHE: case CachedReadBufferFromRemoteFS::ReadType::REMOTE_FS_READ_AND_PUT_IN_CACHE:
elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_FS_BYPASSING_CACHE; elem.read_type = FilesystemCacheLogElement::ReadType::READ_FROM_FS_AND_DOWNLOADED_TO_CACHE;
break; break;
} }

View File

@ -0,0 +1,18 @@
-- { echo }
SYSTEM DROP FILESYSTEM CACHE;
SET enable_filesystem_cache_log=1;
SET enable_filesystem_cache_on_write_operations=0;
DROP TABLE IF EXISTS test;
DROP TABLE IF EXISTS system.filesystem_cache_log;
CREATE TABLE test (key UInt32, value String) Engine=MergeTree() ORDER BY key SETTINGS storage_policy='only_s3', min_bytes_for_wide_part = 10485760;
INSERT INTO test SELECT number, toString(number) FROM numbers(100000);
SELECT * FROM test FORMAT Null;
SYSTEM FLUSH LOGS;
SELECT file_segment_range, read_type FROM system.filesystem_cache_log WHERE read_type='READ_FROM_FS_AND_DOWNLOADED_TO_CACHE';
(0,519) READ_FROM_FS_AND_DOWNLOADED_TO_CACHE
(0,808110) READ_FROM_FS_AND_DOWNLOADED_TO_CACHE
SELECT * FROM test FORMAT Null;
SYSTEM FLUSH LOGS;
SELECT file_segment_range, read_type FROM system.filesystem_cache_log WHERE read_type='READ_FROM_CACHE';
(0,808110) READ_FROM_CACHE

View File

@ -0,0 +1,20 @@
-- Tags: no-parallel, no-fasttest, no-s3-storage
-- { echo }
SYSTEM DROP FILESYSTEM CACHE;
SET enable_filesystem_cache_log=1;
SET enable_filesystem_cache_on_write_operations=0;
DROP TABLE IF EXISTS test;
DROP TABLE IF EXISTS system.filesystem_cache_log;
CREATE TABLE test (key UInt32, value String) Engine=MergeTree() ORDER BY key SETTINGS storage_policy='s3_cache', min_bytes_for_wide_part = 10485760;
INSERT INTO test SELECT number, toString(number) FROM numbers(100000);
SELECT * FROM test FORMAT Null;
SYSTEM FLUSH LOGS;
SELECT file_segment_range, read_type FROM system.filesystem_cache_log WHERE read_type='READ_FROM_FS_AND_DOWNLOADED_TO_CACHE';
SELECT * FROM test FORMAT Null;
SYSTEM FLUSH LOGS;
SELECT file_segment_range, read_type FROM system.filesystem_cache_log WHERE read_type='READ_FROM_CACHE';