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

Interrupt current thread when InterruptException occur #10164

Merged
merged 2 commits into from Jul 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -93,6 +93,10 @@ public Result doInvoke(Invocation invocation, final List<Invoker<T>> invokers, L
if (e.isBiz()) { // biz exception.
throw e;
}
if (e.getCause() != null && InterruptedException.class.getName().equals(e.getCause().toString())) {
// don`t catch interrupt exception
throw new RuntimeException(e);
}
Copy link
Member

Choose a reason for hiding this comment

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

You can choose other fault tolerance strategies, such as cluster="failfast"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a conflict, we need failover strategy at most time, but sometimes due to business needs, I need to interrupt thread pool tasks(which contains dubbo invoke)

Copy link
Member

Choose a reason for hiding this comment

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

Interrupting a thread is not a common scenario, and I don't approve of modifying non-generic logic.
Based on your scenario, I think you may need a custom Cluster implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my code is like this

Future<?> future =RUNNER_EXECUTOR.submit(() -> {
    pipelineService.startTask(taskId);
});
//because some logic error, i need find the future and  cancel task
future.cancel();

i think it is a normal scenario......

Copy link
Member

Choose a reason for hiding this comment

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

For example, if it is not normal behavior to interrupt the thread, dubbo still needs to initiate a retry. If it is modified according to the above logic, the retry capability will be invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i want disable the retry capability when it is initiative inerrupted by login user
i have to copy failover class and use SPI to override the logic at production which seems ugly

Copy link
Member

Choose a reason for hiding this comment

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

I suggest that you can first create an issue to discuss this requirement, so that more people can see and participate in the discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe later, thanks for your patient reply.

le = e;
} catch (Throwable e) {
le = new RpcException(e.getMessage(), e);
Expand Down