-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fix model delete failed after model undeployed #2613
Fix model delete failed after model undeployed #2613
Conversation
Please rebase to take changes from #2627. Thanks. |
407b073
to
2e02989
Compare
Signed-off-by: zane-neo <[email protected]>
Signed-off-by: zane-neo <[email protected]>
2e02989
to
a6cc76e
Compare
what's the root cause? |
Added more details in the description. |
Which flaky IT is fixed from this change? |
@@ -7,13 +7,16 @@ | |||
|
|||
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX; | |||
import static org.opensearch.ml.common.CommonValue.UNDEPLOYED; | |||
import static org.opensearch.ml.plugin.MachineLearningPlugin.DEPLOY_THREAD_POOL; |
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.
Is it possible that multiple Undeploy actions blocking the Deploy_Thread_Pool will cause "Deploy" to fail?
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.
Most of cases, the update index completes immediately which means there's no actual blocking here. In edge cases, if the update completes relatively slow, the requests will be queued. In a more edge case, the queue is full, then the deploy model will fail. But this usually mean the system is not in a correct status(updating index taking too long time). Also this failure is recoverable which doesn't seem a critical issue.
} | ||
if (countDownLatch.getCount() != 0) { | ||
try { | ||
boolean success = countDownLatch.await(1000, TimeUnit.MILLISECONDS); |
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.
Is this 1 second too large? In most cases the update index happen pretty fast.
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 at most
value, if the update index happens within 1s, the await will break immediately after it's done. If update takes more than 1s, then await waits at most 1s to break.
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 will block current thread, which not recommended. We saw issues several times for such blocking thread code
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.
If you're not blocking event loop thread, it's safe.
Check this issue: #2560 |
@zane-neo I remember we have add immediate refresh policy . Why that can't work? |
Please check the description, simply put, this is a race condition issue that updating document and responding to user happens at the same time, no sequence guarantee. |
Checked again on the issue, this fix is not fixing the root cause. When using a script like below to reproduce the issue:
This issue can be reproduce occasionally, but if adding This issue is not able to reproduced easily on local, so will add logs in the delete model action to clearly show the model status when it's not in a deletable status, and closing this PR now. |
Description
When deleting a model, we need to check the model status by querying the model index: https://github.com/opensearch-project/ml-commons/blob/main/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java#L108, which means when undepdeloying model response returns, we have to make sure the model status in index is updated to
DELETED
.But in UndeployModelTransportAction there's no such guarantee, when updating the model index: https://github.com/opensearch-project/ml-commons/blob/main/plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelAction.java#L192, the response returns almost at the same time when the each node's undeploy finished: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/action/support/nodes/TransportNodesAction.java#L315. Which means updating index and response to client run in parallel, so this issue happens occasionally.
So we need a mechanism to guarantee only when the update model index is completed, the response to client get run by adding a countdownlatch to block the response client action when updating index. This is safe to block since this
newResponse
method runs in a threadpool instead of the event loop threads. I also changed the threadpool to model deploy threadpool which is dedicated for deploy/undeploy model instead of management threadpool.Issues Resolved
#2419
#2560
Check List
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.