diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp index 28dfd73b980..f87b68a7038 100644 --- a/src/Core/Settings.cpp +++ b/src/Core/Settings.cpp @@ -5217,7 +5217,7 @@ Only in ClickHouse Cloud. Wait time in milliseconds to receive connection from c DECLARE(Bool, distributed_cache_bypass_connection_pool, false, R"( Only in ClickHouse Cloud. Allow to bypass distributed cache connection pool )", 0) \ - DECLARE(DistributedCachePoolBehaviourOnLimit, distributed_cache_pool_behaviour_on_limit, DistributedCachePoolBehaviourOnLimit::ALLOCATE_NEW_BYPASSING_POOL, R"( + DECLARE(DistributedCachePoolBehaviourOnLimit, distributed_cache_pool_behaviour_on_limit, DistributedCachePoolBehaviourOnLimit::WAIT, R"( Only in ClickHouse Cloud. Identifies behaviour of distributed cache connection on pool limit reached )", 0) \ DECLARE(UInt64, distributed_cache_read_alignment, 0, R"( @@ -5231,6 +5231,9 @@ Only in ClickHouse Cloud. A window for sending ACK for DataPacket sequence in a )", 0) \ DECLARE(Bool, distributed_cache_discard_connection_if_unread_data, true, R"( Only in ClickHouse Cloud. Discard connection if some data is unread. +)", 0) \ + DECLARE(Bool, distributed_cache_min_bytes_for_seek, 0, R"( +Only in ClickHouse Cloud. Minimum number of bytes to do seek in distributed cache. )", 0) \ DECLARE(Bool, filesystem_cache_enable_background_download_for_metadata_files_in_packed_storage, true, R"( Only in ClickHouse Cloud. Wait time to lock cache for space reservation in filesystem cache diff --git a/src/Core/SettingsChangesHistory.cpp b/src/Core/SettingsChangesHistory.cpp index 8e559c161e6..bcacb259cd9 100644 --- a/src/Core/SettingsChangesHistory.cpp +++ b/src/Core/SettingsChangesHistory.cpp @@ -60,6 +60,7 @@ static std::initializer_listisSeekCheap() && file_offset_of_buffer_end && read_until_position && new_pos < *read_until_position - && new_pos > file_offset_of_buffer_end && new_pos < file_offset_of_buffer_end + read_settings.remote_read_min_bytes_for_seek) + && new_pos > file_offset_of_buffer_end && new_pos < file_offset_of_buffer_end + min_bytes_for_seek) { ProfileEvents::increment(ProfileEvents::RemoteFSLazySeeks); bytes_to_ignore = new_pos - file_offset_of_buffer_end; diff --git a/src/Disks/IO/AsynchronousBoundedReadBuffer.h b/src/Disks/IO/AsynchronousBoundedReadBuffer.h index 7664cc4d386..a36de71b6ac 100644 --- a/src/Disks/IO/AsynchronousBoundedReadBuffer.h +++ b/src/Disks/IO/AsynchronousBoundedReadBuffer.h @@ -28,6 +28,7 @@ public: IAsynchronousReader & reader_, const ReadSettings & settings_, size_t buffer_size_, + size_t min_bytes_for_seek_, AsyncReadCountersPtr async_read_counters_ = nullptr, FilesystemReadPrefetchesLogPtr prefetches_log_ = nullptr); @@ -55,6 +56,7 @@ private: const ImplPtr impl; const ReadSettings read_settings; const size_t buffer_size; + const size_t min_bytes_for_seek; IAsynchronousReader & reader; size_t file_offset_of_buffer_end = 0; diff --git a/src/Disks/ObjectStorages/DiskObjectStorage.cpp b/src/Disks/ObjectStorages/DiskObjectStorage.cpp index c34ae1d3ef3..ea0fec193f5 100644 --- a/src/Disks/ObjectStorages/DiskObjectStorage.cpp +++ b/src/Disks/ObjectStorages/DiskObjectStorage.cpp @@ -732,6 +732,7 @@ std::unique_ptr DiskObjectStorage::readFile( reader, read_settings, buffer_size, + read_settings.remote_read_min_bytes_for_seek, /// Modified in private repo. global_context->getAsyncReadCounters(), global_context->getFilesystemReadPrefetchesLog()); diff --git a/src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp b/src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp index 11b4fc3118d..785eac743c4 100644 --- a/src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp +++ b/src/Disks/tests/gtest_asynchronous_bounded_read_buffer.cpp @@ -51,7 +51,7 @@ TEST_F(AsynchronousBoundedReadBufferTest, setReadUntilPosition) for (bool with_prefetch : {false, true}) { - AsynchronousBoundedReadBuffer read_buffer(createReadBufferFromFileBase(file_path, {}), remote_fs_reader, {}, DBMS_DEFAULT_BUFFER_SIZE); + AsynchronousBoundedReadBuffer read_buffer(createReadBufferFromFileBase(file_path, {}), remote_fs_reader, {}, DBMS_DEFAULT_BUFFER_SIZE, 0); read_buffer.setReadUntilPosition(20); auto try_read = [&](size_t count) diff --git a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp index 1ebda25ceb1..1e5eeaac19e 100644 --- a/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp +++ b/src/Storages/ObjectStorage/StorageObjectStorageSource.cpp @@ -572,6 +572,7 @@ std::unique_ptr StorageObjectStorageSource::createReadBu reader, modified_read_settings, buffer_size, + modified_read_settings.remote_read_min_bytes_for_seek, context_->getAsyncReadCounters(), context_->getFilesystemReadPrefetchesLog());