Skip to content

Commit

Permalink
Add missing sync on indicesThatCannotBeCreated (elastic#97869)
Browse files Browse the repository at this point in the history
If auto-creating multiple indices then the responses may arrive
concurrently so we must properly synchronize modifications to the map of
exceptions. All the other accesses to this map are already properly
synchronized thanks to the `counter`.
  • Loading branch information
DaveCTurner authored Jul 24, 2023
1 parent 2d9ea80 commit 72aef7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/97869.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 97869
summary: Add missing sync on `indicesThatCannotBeCreated`
area: CRUD
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ protected void doRun() {
@Override
public void onFailure(Exception e) {
final Throwable cause = ExceptionsHelper.unwrapCause(e);
if (cause instanceof IndexNotFoundException) {
indicesThatCannotBeCreated.put(index, (IndexNotFoundException) cause);
if (cause instanceof IndexNotFoundException indexNotFoundException) {
synchronized (indicesThatCannotBeCreated) {
indicesThatCannotBeCreated.put(index, indexNotFoundException);
}
} else if ((cause instanceof ResourceAlreadyExistsException) == false) {
// fail all requests involving this index, if create didn't work
for (int i = 0; i < bulkRequest.requests.size(); i++) {
Expand Down

0 comments on commit 72aef7e

Please sign in to comment.