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

Fixing a race condition in EnrichCoordinatorProxyAction that can leave an item stuck in its queue #90688

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
7 changes: 7 additions & 0 deletions docs/changelog/90688.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pr: 90688
summary: Fixing a race condition in `EnrichCoordinatorProxyAction` that can leave
an item stuck in its queue
area: Ingest Node
type: bug
issues:
- 90598
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@ void coordinateLookups() {
final List<Slot> slots = new ArrayList<>(Math.min(queue.size(), maxLookupsPerRequest));
if (queue.drainTo(slots, maxLookupsPerRequest) == 0) {
remoteRequestPermits.release();
return;
/*
* It is possible that something was added to the queue after the drain and before the permit was released, meaning
* that the other thread could not acquire the permit, leaving an item orphaned in the queue. So we check the queue
* again after releasing the permit, and if there is something there we run another loop to pick that thing up. If
* another thread has picked it up in the meantime, we'll just exit out of the loop on the next try.
*/
if (queue.isEmpty()) {
return;
} else {
continue;
}
}
assert slots.isEmpty() == false;
remoteRequestsTotal.increment();
Expand Down