-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Replace EngineClosedException with AlreadyClosedExcpetion #22631
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
Replace EngineClosedException with AlreadyClosedExcpetion #22631
Conversation
s1monw
left a comment
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.
I left one comment
| // and set the error in operation.setFailure. In case of environment related errors, the failure | ||
| // is bubbled up | ||
| isDocumentFailure = maybeFailEngine(operation.operationType().getLowercase(), failure) == false; | ||
| if (failure instanceof EngineClosedException) { |
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.
I am not sure what makes a EngineClosedException not a isDocumetnFailure but AlreadyClosedException does. I think we use the boolean returned from maybeFailEngine in the wrong way here. It almost seems like that we need some state handling on Operation that tells us if the document actually failed to index or if we didn't try or if we tried, succeeded but after success we failed due to concurrent closing. This entire exception based decision making here seems error prone to me.
…eption_doc_failure # Conflicts: # core/src/test/java/org/elasticsearch/index/IndexModuleTests.java # core/src/test/java/org/elasticsearch/index/shard/IndexingOperationListenerTests.java
|
@s1monw as discussed, I update the PR to stop using EngineClosedException. Can you take a look? (PR title and description are adapted as well) |
s1monw
left a comment
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.
left some suggestions
| // check if any transient write operation failures should be bubbled up | ||
| Exception failure = operationResult.getFailure(); | ||
| assert failure instanceof VersionConflictEngineException | ||
| || failure instanceof MapperParsingException |
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.
👍
| new IndexNotFoundException(shardId.getIndex()), | ||
| new IndexShardClosedException(shardId), | ||
| new EngineClosedException(shardId), | ||
| new AlreadyClosedException("primary is closed"), |
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.
maybe put the shard ID into the message just for completeness?
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 is a test only exception, but sure
| return translog.sizeInBytes() > indexSettings.getFlushThresholdSize().getBytes(); | ||
| } catch (AlreadyClosedException | EngineClosedException ex) { | ||
| } catch (AlreadyClosedException ex) { | ||
| // that's fine we are already close - no need to flush |
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.
should we include the shard ID in the message in general?
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.
I'm partial. can do...
|
retest this please |
|
Thx @s1monw |
* master: (131 commits) Replace EngineClosedException with AlreadyClosedExcpetion (elastic#22631) Remove HttpServer and HttpServerAdapter in favor of a simple dispatch method (elastic#22636) move ignore parameter support from yaml test client to low level rest client (elastic#22637) Fix thread safety of Stempel's token filter factory (elastic#22610) Update profile.asciidoc Wrap rest httpclient with doPrivileged blocks (elastic#22603) Revert "Add a deprecation notice to shadow replicas (elastic#22025)" Revert "Don'y use `INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING` directly as it triggers (many) deprecation logging" Don'y use `INDEX_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE_SETTING` directly as it triggers (many) deprecation logging Add a deprecation notice to shadow replicas (elastic#22025) [Docs] Fix section title in profile.asciidoc ProfileResult and CollectorResult should print machine readable timing information (elastic#22561) Add replica ops with version conflict to translog Replace custom Functional interface in ElasticsearchException with CheckedFunction Make RestChannelConsumer extend CheckedConsumer<RestChannel, Exception> replace ShardSearchRequest.FilterParser functional interface with CheckedFunction replace custom functional interface with CheckedFunction in percolate module [TEST] replace SizeFunction with Function<Integer, Integer> Expose CheckedFunction Expose logs base path ...
`EngineClosedException` is a ES level exception that is used to indicate that the engine is closed when operation starts. It doesn't really add much value and we can use `AlreadyClosedException` from Lucene (which may already bubble if things go wrong during operations). Having two exception can just add confusion and lead to bugs, like wrong handling of `EngineClosedException` when dealing with document level failures. The latter was exposed by `IndexWithShadowReplicasIT`. This PR also removes the AwaitFix from the `IndexWithShadowReplicasIT` tests (which was what cause this to be discovered). While debugging the source of the issue I found some mismatches in document uid management in the tests. The term that was passed to the engine didn't correspond to the uid in the parsed doc - those are fixed as well.
All usage has been removed in #22631, which is back ported to 5.x. This means 6.x will never get it on the wire and we can remove it
EngineClosedExceptionis a ES level exception that is used to indicate that the engine is closed when operation starts. It doesn't really add much value and we can useAlreadyClosedExceptionfrom Lucene (which may already bubble if things go wrong during operations). Having two exception can just add confusion and lead to bugs, like wrong handling ofEngineClosedExceptionwhen dealing with document level failures. The latter was exposed byIndexWithShadowReplicasIT.This PR also removes the AwaitFix from the
IndexWithShadowReplicasITtests (which was what cause this to be discovered). While debugging the source of the issue I found some mismatches in document uid management in the tests. The term that was passed to the engine didn't correspond to the uid in the parsed doc - those are fixed as well.EngineClosedExceptionis kept around for BWC. Once this goes into 5.3, I will remove it from master.