Merge pull request #48636 from kssenii/fix-error-in-cache

Fix possible error from cache
This commit is contained in:
Kseniia Sumarokova 2023-04-13 11:03:11 +02:00 committed by GitHub
commit b6c17759f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 5 deletions

View File

@ -617,6 +617,10 @@ void CachedOnDiskReadBufferFromFile::predownload(FileSegmentPtr & file_segment)
continue_predownload = false;
}
}
else
{
file_segment->completeWithState(FileSegment::State::PARTIALLY_DOWNLOADED_NO_CONTINUATION);
}
if (!continue_predownload)
{
@ -636,8 +640,8 @@ void CachedOnDiskReadBufferFromFile::predownload(FileSegmentPtr & file_segment)
/// TODO: allow seek more than once with seek avoiding.
bytes_to_predownload = 0;
file_segment->completeWithState(FileSegment::State::PARTIALLY_DOWNLOADED_NO_CONTINUATION);
chassert(file_segment->state() == FileSegment::State::PARTIALLY_DOWNLOADED_NO_CONTINUATION);
LOG_TEST(log, "Bypassing cache because for {}", file_segment->getInfoForLog());
read_type = ReadType::REMOTE_FS_READ_BYPASS_CACHE;

View File

@ -37,6 +37,7 @@
<disk>s3</disk>
<path>/jbod1/</path>
<max_size>1000000000</max_size>
<max_file_segment_size>1Gi</max_file_segment_size>
</s3_with_cache_and_jbod>
<s3_r>
<type>s3</type>

View File

@ -674,13 +674,22 @@ def test_cache_with_full_disk_space(cluster, node_name):
node = cluster.instances[node_name]
node.query("DROP TABLE IF EXISTS s3_test NO DELAY")
node.query(
"CREATE TABLE s3_test (key UInt32, value String) Engine=MergeTree() ORDER BY key SETTINGS storage_policy='s3_with_cache_and_jbod';"
"CREATE TABLE s3_test (key UInt32, value String) Engine=MergeTree() ORDER BY value SETTINGS storage_policy='s3_with_cache_and_jbod';"
)
node.query(
"INSERT INTO s3_test SELECT * FROM generateRandom('key UInt32, value String') LIMIT 500000"
"INSERT INTO s3_test SELECT number, toString(number) FROM numbers(100000000)"
)
node.query(
"SELECT * FROM s3_test WHERE value LIKE '%abc%' ORDER BY value FORMAT Null"
out = node.exec_in_container(
[
"/usr/bin/clickhouse",
"benchmark",
"--iterations",
"10",
"--max_threads",
"100",
"--query",
"SELECT count() FROM s3_test WHERE key < 40000000 or key > 80000000 SETTINGS max_read_buffer_size='44Ki'",
]
)
assert node.contains_in_log(
"Insert into cache is skipped due to insufficient disk space"