mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #29946 from azat/log-fix-data-race
Fix data-race between LogSink::writeMarks() and LogSource in StorageLog
This commit is contained in:
commit
bc1662b9fe
@ -183,7 +183,10 @@ void LogSource::readData(const NameAndTypePair & name_and_type, ColumnPtr & colu
|
||||
|
||||
UInt64 offset = 0;
|
||||
if (!stream_for_prefix && mark_number)
|
||||
{
|
||||
std::lock_guard marks_lock(file_it->second.marks_mutex);
|
||||
offset = file_it->second.marks[mark_number].offset;
|
||||
}
|
||||
|
||||
auto & data_file_path = file_it->second.data_file_path;
|
||||
auto it = streams.try_emplace(stream_name, storage.disk, data_file_path, offset, read_settings).first;
|
||||
@ -457,7 +460,10 @@ void LogSink::writeMarks(MarksForColumns && marks)
|
||||
writeIntBinary(mark.second.offset, *marks_stream);
|
||||
|
||||
size_t column_index = mark.first;
|
||||
storage.files[storage.column_names_by_idx[column_index]].marks.push_back(mark.second);
|
||||
|
||||
auto & file = storage.files[storage.column_names_by_idx[column_index]];
|
||||
std::lock_guard marks_lock(file.marks_mutex);
|
||||
file.marks.push_back(mark.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,8 @@ private:
|
||||
size_t column_index;
|
||||
|
||||
String data_file_path;
|
||||
|
||||
std::mutex marks_mutex;
|
||||
Marks marks;
|
||||
};
|
||||
using Files = std::map<String, ColumnData>; /// file name -> column data
|
||||
|
Loading…
Reference in New Issue
Block a user