Skip to content

Commit

Permalink
fix tsan fail in unit test JoinExecutorTestRunner.MultiJoin (pingca…
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaRise authored and guo-shaoge committed Feb 10, 2023
1 parent c6493d4 commit 76e725e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions dbms/src/Interpreters/Join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions dbms/src/Interpreters/Join.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(totals); };
void setTotals(const Block & block)
{
std::unique_lock lock(rwlock);
totals = block;
}
bool hasTotals() const
{
std::shared_lock lock(rwlock);
return static_cast<bool>(totals);
};

void joinTotals(Block & block) const;

Expand Down

0 comments on commit 76e725e

Please sign in to comment.