Skip to content

Commit

Permalink
GH-3638: Fixes bug caused by race condition during handleAsyncFailure()
Browse files Browse the repository at this point in the history
Fixes: #3638 

Issue: #3638
  • Loading branch information
chickenchickenlove authored Nov 18, 2024
1 parent efbd396 commit c155336
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,14 @@ protected void pollAndInvoke() {

protected void handleAsyncFailure() {
List<FailedRecordTuple<K, V>> copyFailedRecords = new ArrayList<>(this.failedRecords);
this.failedRecords.clear();

// If we use failedRecords.clear() to remove copied record from failed records,
// We may encounter race condition during this operation.
// Other, the thread which execute this block, may miss one failed record.
int capturedRecordsCount = copyFailedRecords.size();
for (int i = 0; i < capturedRecordsCount; i++) {
this.failedRecords.pollFirst();
}

// If any copied and failed record fails to complete due to an unexpected error,
// We will give up on retrying with the remaining copied and failed Records.
Expand Down

0 comments on commit c155336

Please sign in to comment.