From 9a0ae45e500024ad6022fb1aed2a855319505e19 Mon Sep 17 00:00:00 2001 From: kssenii Date: Tue, 3 Dec 2024 12:21:35 +0100 Subject: [PATCH] Fix --- src/Interpreters/Cache/FileCache.cpp | 1 - src/Interpreters/Cache/FileSegment.cpp | 13 ++++++------- .../configs/config.d/storage_conf.xml | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Interpreters/Cache/FileCache.cpp b/src/Interpreters/Cache/FileCache.cpp index 8e8109f8067..a8900d5eebb 100644 --- a/src/Interpreters/Cache/FileCache.cpp +++ b/src/Interpreters/Cache/FileCache.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Interpreters/Cache/FileSegment.cpp b/src/Interpreters/Cache/FileSegment.cpp index 2f4bc828113..7c2c5f4c60b 100644 --- a/src/Interpreters/Cache/FileSegment.cpp +++ b/src/Interpreters/Cache/FileSegment.cpp @@ -392,12 +392,6 @@ void FileSegment::write(char * from, size_t size, size_t offset_in_file) range().size(), first_non_downloaded_offset, size, current_downloaded_size); } } - - if (!cache_writer && current_downloaded_size > 0) - throw Exception( - ErrorCodes::LOGICAL_ERROR, - "Cache writer was finalized (downloaded size: {}, state: {})", - current_downloaded_size, stateToString(download_state)); } try @@ -409,7 +403,12 @@ void FileSegment::write(char * from, size_t size, size_t offset_in_file) #endif if (!cache_writer) - cache_writer = std::make_unique(getPath(), /* buf_size */0); + { + int flags = -1; + if (downloaded_size > 0) + flags = O_WRONLY | O_APPEND | O_CLOEXEC; + cache_writer = std::make_unique(getPath(), /* buf_size */0, flags); + } /// Size is equal to offset as offset for write buffer points to data end. cache_writer->set(from, /* size */size, /* offset */size); diff --git a/tests/integration/test_merge_tree_s3/configs/config.d/storage_conf.xml b/tests/integration/test_merge_tree_s3/configs/config.d/storage_conf.xml index 7087c348072..b7b1bd146a4 100644 --- a/tests/integration/test_merge_tree_s3/configs/config.d/storage_conf.xml +++ b/tests/integration/test_merge_tree_s3/configs/config.d/storage_conf.xml @@ -64,6 +64,7 @@ s3 /jbod1/ 1000000000 + 20Ki 1Gi