From ca390134ce1a29a344b5eb62cc2f1d35f9bf574c Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Mon, 10 Oct 2022 10:45:49 +0800 Subject: [PATCH] Fix data race of DeltaIndex::toString (#5948) (#5954) close pingcap/tiflash#5947 --- dbms/src/Storages/DeltaMerge/DeltaIndex.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dbms/src/Storages/DeltaMerge/DeltaIndex.h b/dbms/src/Storages/DeltaMerge/DeltaIndex.h index 8c83a0d03fa..9eda0b75870 100644 --- a/dbms/src/Storages/DeltaMerge/DeltaIndex.h +++ b/dbms/src/Storages/DeltaMerge/DeltaIndex.h @@ -145,10 +145,13 @@ class DeltaIndex String toString() { - std::stringstream s; - s << "{placed rows:" << placed_rows << ", deletes:" << placed_deletes << ", delta tree: " << delta_tree->numEntries() << "|" - << delta_tree->numInserts() << "|" << delta_tree->numDeletes() << "}"; - return s.str(); + std::scoped_lock lock(mutex); + return fmt::format("", + placed_rows, + placed_deletes, + delta_tree->numEntries(), + delta_tree->numInserts(), + delta_tree->numDeletes()); } UInt64 getId() const { return id; }