Skip to content

Commit e4db862

Browse files
committed
Fix possible data-race between FileChecker and StorageLog/StorageStripeLog
1 parent a163230 commit e4db862

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/Storages/StorageLog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <Parsers/ASTLiteral.h>
2525
#include "StorageLogSettings.h"
2626
#include <Processors/Sources/SourceWithProgress.h>
27+
#include <Processors/Sources/NullSource.h>
2728
#include <Processors/Pipe.h>
2829
#include <Processors/Sinks/SinkToStorage.h>
2930

@@ -122,9 +123,6 @@ Chunk LogSource::generate()
122123
if (rows_read == rows_limit)
123124
return {};
124125

125-
if (storage.file_checker.empty())
126-
return {};
127-
128126
/// How many rows to read for the next block.
129127
size_t max_rows_to_read = std::min(block_size, rows_limit - rows_read);
130128
std::unordered_map<String, ISerialization::SubstreamsCache> caches;
@@ -672,6 +670,9 @@ Pipe StorageLog::read(
672670
if (!lock)
673671
throw Exception("Lock timeout exceeded", ErrorCodes::TIMEOUT_EXCEEDED);
674672

673+
if (file_checker.empty())
674+
return Pipe(std::make_shared<NullSource>(metadata_snapshot->getSampleBlockForColumns(column_names, getVirtuals(), getStorageID())));
675+
675676
Pipes pipes;
676677

677678
const Marks & marks = getMarksWithRealRowCount(metadata_snapshot);

src/Storages/StorageStripeLog.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ class StripeLogSource final : public SourceWithProgress
9898
protected:
9999
Chunk generate() override
100100
{
101-
if (storage.file_checker.empty())
102-
return {};
103-
104101
Block res;
105102
start();
106103

@@ -337,7 +334,7 @@ Pipe StorageStripeLog::read(
337334
Pipes pipes;
338335

339336
String index_file = table_path + "index.mrk";
340-
if (!disk->exists(index_file))
337+
if (file_checker.empty() || !disk->exists(index_file))
341338
{
342339
return Pipe(std::make_shared<NullSource>(metadata_snapshot->getSampleBlockForColumns(column_names, getVirtuals(), getStorageID())));
343340
}

0 commit comments

Comments
 (0)