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

stash thread context before running forward action #1904

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.xcontent.NamedXContentRegistry;
Expand Down Expand Up @@ -161,13 +162,15 @@
.build();
MLForwardRequest deployModelDoneMessage = new MLForwardRequest(mlForwardInput);

transportService
.sendRequest(
getNodeById(coordinatingNodeId),
MLForwardAction.NAME,
deployModelDoneMessage,
new ActionListenerResponseHandler<>(taskDoneListener, MLForwardResponse::new)
);
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change should fix the issue when multiple threads running in progress.

transportService
.sendRequest(
getNodeById(coordinatingNodeId),

Check warning on line 168 in plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java#L165-L168

Added lines #L165 - L168 were not covered by tests
MLForwardAction.NAME,
deployModelDoneMessage,
new ActionListenerResponseHandler<>(taskDoneListener, MLForwardResponse::new)
);
}
}, e -> {
MLForwardInput mlForwardInput = MLForwardInput
.builder()
Expand All @@ -179,13 +182,15 @@
.build();
MLForwardRequest deployModelDoneMessage = new MLForwardRequest(mlForwardInput);

transportService
.sendRequest(
getNodeById(coordinatingNodeId),
MLForwardAction.NAME,
deployModelDoneMessage,
new ActionListenerResponseHandler<>(taskDoneListener, MLForwardResponse::new)
);
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
transportService
.sendRequest(
getNodeById(coordinatingNodeId),

Check warning on line 188 in plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java#L185-L188

Added lines #L185 - L188 were not covered by tests
MLForwardAction.NAME,
deployModelDoneMessage,
new ActionListenerResponseHandler<>(taskDoneListener, MLForwardResponse::new)
);
}
})
);

Expand Down
Loading