diff --git a/dbms/src/Interpreters/Join.cpp b/dbms/src/Interpreters/Join.cpp index f54b8bd51c3..b1eb6139128 100644 --- a/dbms/src/Interpreters/Join.cpp +++ b/dbms/src/Interpreters/Join.cpp @@ -2136,6 +2136,7 @@ bool Join::needReturnNonJoinedData() const void Join::joinTotals(Block & block) const { + std::shared_lock lock(rwlock); Block totals_without_keys = totals; if (totals_without_keys) diff --git a/dbms/src/Interpreters/Join.h b/dbms/src/Interpreters/Join.h index c3e6e218b5c..abae6268430 100644 --- a/dbms/src/Interpreters/Join.h +++ b/dbms/src/Interpreters/Join.h @@ -122,8 +122,16 @@ class Join /** Keep "totals" (separate part of dataset, see WITH TOTALS) to use later. */ - void setTotals(const Block & block) { totals = block; } - bool hasTotals() const { return static_cast(totals); }; + void setTotals(const Block & block) + { + std::unique_lock lock(rwlock); + totals = block; + } + bool hasTotals() const + { + std::shared_lock lock(rwlock); + return static_cast(totals); + }; void joinTotals(Block & block) const;