-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Remove compareAndSet in failure handling #94609
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
Conversation
Instead of a compareAndSet followed by an accumulateAndGet, just use a single accumulateAndGet for everything.
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all seems very complicated compared with the approach in RefCountingListener. Either this can be simplified, or RefCountingListener has a bug...
elasticsearch/server/src/main/java/org/elasticsearch/action/support/RefCountingListener.java
Lines 215 to 218 in d875dc2
| final var firstException = exceptionRef.compareAndExchange(null, e); | |
| if (firstException != null && firstException != e) { | |
| firstException.addSuppressed(e); | |
| } |
|
I'm good with that solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible!
As requested in #92308 (comment) (which I'm finally getting back to, yikes!).
Instead of a
compareAndSetfollowed by anaccumulateAndGet, just use a singleaccumulateAndGetcompareAndExchangefor everything.I'm 97.5% sure the logic of this remains correct, and I think it's simpler this way, but if somebody can point out a bug in the logic or disagrees about it being simpler, I'm happy to change or close this PR.
For a bit of the history on this, see
https://github.com/elastic/elasticsearch/pull/23969(code highlighting to avoid a github reference being added), as well as #37649 and #53262.