Merge pull request #29959 from azat/log-data-race-file-checker-fix

Fix possible data-race between FileChecker and StorageLog/StorageStripeLog
This commit is contained in:
alexey-milovidov 2021-10-15 01:30:23 +03:00 committed by GitHub
commit 8d694cbcdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include <Parsers/ASTLiteral.h>
#include "StorageLogSettings.h"
#include <Processors/Sources/SourceWithProgress.h>
#include <Processors/Sources/NullSource.h>
#include <Processors/Pipe.h>
#include <Processors/Sinks/SinkToStorage.h>
@ -122,9 +123,6 @@ Chunk LogSource::generate()
if (rows_read == rows_limit)
return {};
if (storage.file_checker.empty())
return {};
/// How many rows to read for the next block.
size_t max_rows_to_read = std::min(block_size, rows_limit - rows_read);
std::unordered_map<String, ISerialization::SubstreamsCache> caches;
@ -672,6 +670,9 @@ Pipe StorageLog::read(
if (!lock)
throw Exception("Lock timeout exceeded", ErrorCodes::TIMEOUT_EXCEEDED);
if (file_checker.empty())
return Pipe(std::make_shared<NullSource>(metadata_snapshot->getSampleBlockForColumns(column_names, getVirtuals(), getStorageID())));
Pipes pipes;
const Marks & marks = getMarksWithRealRowCount(metadata_snapshot);

View File

@ -98,9 +98,6 @@ public:
protected:
Chunk generate() override
{
if (storage.file_checker.empty())
return {};
Block res;
start();
@ -337,7 +334,7 @@ Pipe StorageStripeLog::read(
Pipes pipes;
String index_file = table_path + "index.mrk";
if (!disk->exists(index_file))
if (file_checker.empty() || !disk->exists(index_file))
{
return Pipe(std::make_shared<NullSource>(metadata_snapshot->getSampleBlockForColumns(column_names, getVirtuals(), getStorageID())));
}