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

Replace EngineClosedException with AlreadyClosedExcpetion #22631

Merged
merged 11 commits into from
Jan 16, 2017

Conversation

bleskes
Copy link
Contributor

@bleskes bleskes commented Jan 15, 2017

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.

EngineClosedException is kept around for BWC. Once this goes into 5.3, I will remove it from master.

Copy link
Contributor

@s1monw s1monw left a 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

@@ -544,6 +544,10 @@ final Exception checkIfDocumentFailureOrThrow(final Operation operation, final E
// 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) {
Copy link
Contributor

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
@bleskes bleskes changed the title EngineClosedException shouldn't be treated as a doc level failure Replace EngineClosedException with AlreadyClosedExcpetion Jan 16, 2017
@bleskes
Copy link
Contributor Author

bleskes commented Jan 16, 2017

@s1monw as discussed, I update the PR to stop using EngineClosedException. Can you take a look? (PR title and description are adapted as well)

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some suggestions

@@ -388,8 +386,6 @@ private UpdateResultHolder executeUpdateRequest(UpdateRequest updateRequest, Ind
Exception failure = operationResult.getFailure();
assert failure instanceof VersionConflictEngineException
|| failure instanceof MapperParsingException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return randomFrom(
new ShardNotFoundException(shardId),
new IndexNotFoundException(shardId.getIndex()),
new IndexShardClosedException(shardId),
new EngineClosedException(shardId),
new AlreadyClosedException("primary is closed"),
Copy link
Contributor

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?

Copy link
Contributor Author

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

@@ -1667,7 +1666,7 @@ public void onFailedEngine(String reason, @Nullable Exception failure) {
private Engine createNewEngine(EngineConfig config) {
synchronized (mutex) {
if (state == IndexShardState.CLOSED) {
throw new EngineClosedException(shardId);
throw new AlreadyClosedException("can't create engine - shard is closed");
Copy link
Contributor

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?

Copy link
Contributor Author

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...

@bleskes
Copy link
Contributor Author

bleskes commented Jan 16, 2017

retest this please

@bleskes bleskes merged commit d80e3ee into elastic:master Jan 16, 2017
@bleskes
Copy link
Contributor Author

bleskes commented Jan 16, 2017

Thx @s1monw

@bleskes bleskes deleted the engine_closed_exception_doc_failure branch January 16, 2017 20:14
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 16, 2017
* 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
  ...
bleskes added a commit that referenced this pull request Jan 19, 2017
`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.
bleskes added a commit that referenced this pull request Jan 25, 2017
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
@clintongormley clintongormley added :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Engine :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >enhancement v5.3.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants