Skip to content

Handle ResourceAlreadyExistsException in FlowFrameworkIndicesHandler#1378

Merged
dbwiddis merged 1 commit into
opensearch-project:mainfrom
dbwiddis:fix/handle-resource-already-exists-race-condition
May 6, 2026
Merged

Handle ResourceAlreadyExistsException in FlowFrameworkIndicesHandler#1378
dbwiddis merged 1 commit into
opensearch-project:mainfrom
dbwiddis:fix/handle-resource-already-exists-race-condition

Conversation

@dbwiddis
Copy link
Copy Markdown
Member

@dbwiddis dbwiddis commented May 4, 2026

Description

Fixes a race condition in FlowFrameworkIndicesHandler.initFlowFrameworkIndexIfAbsent() where concurrent index creation requests on a multi-node cluster can fail with a 400 BAD_REQUEST error.

When two nodes simultaneously check doesIndexExistMultitenant() and both get false, the second CreateIndexRequest throws ResourceAlreadyExistsException. Previously this was treated as a failure. Now it is treated as success, since the index exists (which is the desired state).

This matches the pattern used by ML Commons' MLIndicesHandler.

Resolves #1377

Issues Resolved

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff
  • Changelog entry added

When multiple nodes attempt to create a system index simultaneously,
the second request receives a ResourceAlreadyExistsException. This is
not a true failure since the index exists, which is the desired state.

Treat ResourceAlreadyExistsException (and its OpenSearchWrapperException
variant) as a success condition in initFlowFrameworkIndexIfAbsent(),
matching the pattern used by ML Commons' MLIndicesHandler.

Resolves opensearch-project#1377

Signed-off-by: Daniel Widdis <widdis@gmail.com>
Signed-off-by: Dan Widdis <widdisd@amazon.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.38%. Comparing base (f235210) to head (3afca03).

Files with missing lines Patch % Lines
...framework/indices/FlowFrameworkIndicesHandler.java 25.00% 4 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (25.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1378      +/-   ##
============================================
- Coverage     78.38%   78.38%   -0.01%     
- Complexity     1306     1308       +2     
============================================
  Files           106      106              
  Lines          6015     6019       +4     
  Branches        640      641       +1     
============================================
+ Hits           4715     4718       +3     
+ Misses         1013     1012       -1     
- Partials        287      289       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbwiddis dbwiddis merged commit 95f7e6a into opensearch-project:main May 6, 2026
38 of 39 checks passed
@dbwiddis dbwiddis deleted the fix/handle-resource-already-exists-race-condition branch May 6, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Race condition in FlowFrameworkIndicesHandler when creating system indices

2 participants