Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32789 Fix potential race deadlock in Thor splitter #19235

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions thorlcr/thorutil/thbuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,10 @@ class CRowSet : public CSimpleInterface, implements IInterface
{
return rows.get(r);
}
inline bool isFull() const
{
return rows.isFull();
}
};

class Chunk : public CInterface
Expand Down Expand Up @@ -1463,8 +1467,7 @@ class CSharedWriteAheadBase : public CSimpleInterface, implements ISharedSmartBu
}
}
rowsRead++;
const void *retrow = rowSet->getRow(row++);
return retrow;
return rowSet->getRow(row++);
}
virtual void stop()
{
Expand Down Expand Up @@ -1693,7 +1696,8 @@ class CSharedWriteAheadBase : public CSimpleInterface, implements ISharedSmartBu
unsigned len=rowSize(row);
CriticalBlock b(crit);
bool paged = false;
if (totalOutChunkSize >= minChunkSize) // chunks required to be at least minChunkSize
// NB: The isFull condition ensures that we never expand inMemRows, which would cause a race with readers reading same set
if (totalOutChunkSize >= minChunkSize || inMemRows->isFull()) // chunks required to be at least minChunkSize, or if hits max capacity
{
unsigned reader=anyReaderBehind();
if (NotFound != reader)
Expand Down
4 changes: 3 additions & 1 deletion thorlcr/thorutil/thmem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ class graph_decl CThorExpandingRowArray : public CSimpleInterface
if (!resize(numRows+1))
return false;
}
rows[numRows++] = row;
rows[numRows] = row;
numRows++;
return true;
}
bool binaryInsert(const void *row, ICompare &compare, bool dropLast=false); // NB: takes ownership on success
Expand Down Expand Up @@ -356,6 +357,7 @@ class graph_decl CThorExpandingRowArray : public CSimpleInterface
}
inline rowidx_t ordinality() const { return numRows; }
inline rowidx_t queryMaxRows() const { return maxRows; }
inline bool isFull() const { return numRows >= maxRows; }

inline const void **getRowArray() { return rows; }
void swap(CThorExpandingRowArray &src);
Expand Down
Loading