Skip to content

Commit

Permalink
Pipe: fix threads of IoTDB-Pipe-Processor-Executor-Pool stucked by Pi…
Browse files Browse the repository at this point in the history
…peTsFileInsertionEvent#waitForTsFileClose (#12727)
  • Loading branch information
SteveYurongSu authored Jun 13, 2024
1 parent 273d483 commit db05137
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,22 @@ public PipeTsFileInsertionEvent(
*/
public boolean waitForTsFileClose() throws InterruptedException {
if (!isClosed.get()) {
isClosed.set(resource.isClosed());

synchronized (isClosed) {
while (!isClosed.get()) {
isClosed.wait();
isClosed.wait(100);

final boolean isClosedNow = resource.isClosed();
if (isClosedNow) {
isClosed.set(true);
isClosed.notifyAll();
break;
}
}
}
}

// From illustrations above we know If the status is "closed", then the tsFile is flushed
// And here we guarantee that the isEmpty() is set before flushing if tsFile is empty
// Then we know: "isClosed" --> tsFile flushed --> (isEmpty() <--> tsFile is empty)
Expand Down

0 comments on commit db05137

Please sign in to comment.