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

Handling exception in getAssignment method #881

Merged
merged 2 commits into from
May 31, 2023
Merged

Handling exception in getAssignment method #881

merged 2 commits into from
May 31, 2023

Conversation

nisgoel-amazon
Copy link
Contributor

Handling exception in getAssignment method

Description

getAssignment method is used to assign shard replication task via persistent task cluster service. In case of stale entries present in persistent tasks in cluster state when this method is trying to assign task it is not handled properly.

Most of the times stale entries are not present in cluster state as we are clearing them at the time of cancelling the replication task but if cancelling is failed by any reason then these entries can remain in the cluster state.

Issues Resolved

#880

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>
@nisgoel-amazon nisgoel-amazon requested a review from gbbafna as a code owner May 23, 2023 11:25
@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Merging #881 (10b3104) into main (3e3787d) will decrease coverage by 26.22%.
The diff coverage is 37.50%.

❗ Current head 10b3104 differs from pull request most recent head e6a1398. Consider uploading reports for the commit e6a1398 to get more accurate results

@@              Coverage Diff              @@
##               main     #881       +/-   ##
=============================================
- Coverage     72.39%   46.18%   -26.22%     
+ Complexity     1007      630      -377     
=============================================
  Files           141      141               
  Lines          4695     4699        +4     
  Branches        527      527               
=============================================
- Hits           3399     2170     -1229     
- Misses          963     2270     +1307     
+ Partials        333      259       -74     
Impacted Files Coverage Δ
...arch/replication/task/autofollow/AutoFollowTask.kt 0.63% <0.00%> (-72.16%) ⬇️
...replication/task/shard/ShardReplicationExecutor.kt 56.25% <42.85%> (-18.75%) ⬇️

... and 72 files with indirect coverage changes

ankitkala
ankitkala previously approved these changes May 23, 2023
@nisgoel-amazon
Copy link
Contributor Author

Security and knn tests are failing due to known build failures with security plugin

ERROR][o.o.s.f.SecurityFilter   ] [leaderCluster-0] Unexpected exception java.lang.NoSuchMethodError: 'boolean org.opensearch.common.Strings.isNullOrEmpty(java.lang.String)'
»  java.lang.NoSuchMethodError: 'boolean org.opensearch.common.Strings.isNullOrEmpty(java.lang.String)'
»  	at org.opensearch.security.privileges.PrivilegesEvaluator.setUserInfoInThreadContext(PrivilegesEvaluator.java:204) ~[opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.security.privileges.PrivilegesEvaluator.evaluate(PrivilegesEvaluator.java:248) ~[opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:303) [opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149) [opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:216) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.action.support.TransportAction.execute(TransportAction.java:188) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.action.support.TransportAction.execute(TransportAction.java:107) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:476) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.client.support.AbstractClient$ClusterAdmin.execute(AbstractClient.java:788) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.client.support.AbstractClient$ClusterAdmin.health(AbstractClient.java:803) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.rest.action.admin.cluster.RestClusterHealthAction.lambda$prepareRequest$0(RestClusterHealthAction.java:85) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:128) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.security.filter.SecurityRestFilter$1.handleRequest(SecurityRestFilter.java:127) [opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.rest.RestController.dispatchRequest(RestController.java:320) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.rest.RestController.tryAllHandlers(RestController.java:411) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.rest.RestController.dispatchRequest(RestController.java:249) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.security.ssl.http.netty.ValidatingDispatcher.dispatchRequest(ValidatingDispatcher.java:63) [opensearch-security-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
ERROR][o.o.b.OpenSearchUncaughtExceptionHandler] [followCluster-0] fatal error in thread [DefaultDispatcher-worker-1 @coroutine#1], exiting
»  java.lang.NoClassDefFoundError: org/opensearch/core/common/Strings
»  	at org.opensearch.commons.authuser.User.parse(User.java:162) ~[common-utils-3.0.0.0-SNAPSHOT.jar:?]
»  	at org.opensearch.replication.util.SecurityContext$Companion.fromSecurityThreadContext(SecurityContext.kt:65) ~[opensearch-cross-cluster-replication-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]
»  	at org.opensearch.replication.action.index.TransportReplicateIndexAction$doExecute$1.invokeSuspend(TransportReplicateIndexAction.kt:66) ~[opensearch-cross-cluster-replication-3.0.0.0-SNAPSHOT.jar:3.0.0.0-SNAPSHOT]

@monusingh-1
Copy link
Collaborator

@nisgoel-amazon will this be backported to all other branches ?

@nisgoel-amazon
Copy link
Contributor Author

@nisgoel-amazon will this be backported to all other branches ?

yes

} catch (e: Exception) {
log.error("Failed to assign shard replication task with id ${params.followerShardId}", e)
return SHARD_NOT_ACTIVE
}
}
Copy link
Member

@saikaranam-amazon saikaranam-amazon May 24, 2023

Choose a reason for hiding this comment

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

Let's add UTs for the assignment logic and can we validate the changes required for Index Replication task as well? (if any)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Index Replication task does not attach to particular node, so there assignment can happen on any node.
Those tasks are working fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

UT has been added

if (!primaryShard.active()) return SHARD_NOT_ACTIVE
return Assignment(primaryShard.currentNodeId(), "node with primary shard")
try {
val primaryShard = clusterState.routingTable().shardRoutingTable(params.followerShardId).primaryShard()
Copy link
Member

Choose a reason for hiding this comment

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

For testing, will _stop API clear these entries when the shards are not active?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this we are taking another issue
#903

@ankitkala ankitkala merged commit 14b9268 into opensearch-project:main May 31, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
opensearch-trigger-bot bot pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)
@nisgoel-amazon nisgoel-amazon deleted the patch-1 branch May 31, 2023 09:12
ankitkala pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method



* Adding UT for getAssignment Method



---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
ankitkala pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

Co-authored-by: Nishant Goel <[email protected]>
ankitkala pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

Co-authored-by: Nishant Goel <[email protected]>
ankitkala pushed a commit that referenced this pull request May 31, 2023
* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

Co-authored-by: Nishant Goel <[email protected]>
soosinha pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)
ankitkala pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)

Co-authored-by: Nishant Goel <[email protected]>
ankitkala pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)

Co-authored-by: Nishant Goel <[email protected]>
monusingh-1 pushed a commit that referenced this pull request Jun 1, 2023
* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)

Co-authored-by: Nishant Goel <[email protected]>
monusingh-1 pushed a commit that referenced this pull request Jun 2, 2023
* Handling exception in getAssignment method (#937)

* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
monusingh-1 pushed a commit that referenced this pull request Jun 2, 2023
* Handling exception in getAssignment method (#937)

* Handling exception in getAssignment method (#881)

* Handling exception in getAssignment method

Handling exception in getAssignment method

Signed-off-by: Nishant Goel <[email protected]>

Signed-off-by: Nishant Goel <[email protected]>

* Adding UT for getAssignment Method

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 14b9268)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
(cherry picked from commit 2c28901)

* Fixing build

Signed-off-by: Nishant Goel <[email protected]>

---------

Signed-off-by: Nishant Goel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants