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

Avoid interrupting jetty threads #10987

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

arhimondr
Copy link
Contributor

Description

Driver methods such as Driver#updateSplitAssignment can be ran from a
thread other than a thread created by TaskExecutor. Interrupting a
thread that is not managed by the engine is potentially unsafe.

For example the Jetty server may preserve the "interrupted" flag in between
requests, potentially impacting a different task or a query:
jetty/jetty.project#7548

While the issue in Jetty is likely a bug that will be fixed there is no
real reason why to interrupt a method other than Driver#process (which
is only invoked by the TaskExecutor).

Other driver methods (such as Driver#updateSplitAssignment) are
lightweight and shouldn't take any significant time to finish while the
interrupt mechanism is rather intended to terminate a processing
that could potentially take a significant amount of time.

General information

Fixes #10773

Direct link to a comment describing the problem: #10773 (comment)

Related issues, pull requests, and links

jetty/jetty.project#7548

Documentation

No documentation is needed.

Release notes

No release notes entries required.

@linzebing
Copy link
Member

Nit:tryWithLockUninterrupted -> tryWithLockUninterruptibly

@findepi findepi requested a review from dain February 9, 2022 08:28
Driver methods such as Driver#updateSplitAssignment can be ran from a
thread other than a thread created by TaskExecutor. Interrupting a
thread that is not managed by the engine is potentially unsafe.

For example the Jetty server may preserve the "interrupted" flag in between
requests, potentially impacting a different task or a query:
jetty/jetty.project#7548

While the issue in Jetty is likely a bug that will be fixed there is no
real reason why to interrupt a method other than Driver#process (which
is only invoked by the TaskExecutor).

Other driver methods (such as Driver#updateSplitAssignment) are
lightweight and shouldn't take any significant time to finish while the
interrupt mechanism is rather intended to terminate a processing
that could potentially take a significant amount of time.
@arhimondr arhimondr force-pushed the avoid-interrupting-jetty-threads branch from 507e200 to 5ded6b1 Compare February 9, 2022 19:33
@losipiuk
Copy link
Member

@dain PTAL - it is your area.

Copy link
Member

@sopel39 sopel39 left a comment

Choose a reason for hiding this comment

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

nit: is it possible to write a test?

}

// Note: task cannot return null
private <T> Optional<T> tryWithLock(long timeout, TimeUnit unit, Supplier<T> task)
Copy link
Member

Choose a reason for hiding this comment

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

nit: keep this method maybe so that you don't have to add true argument for existing tryWithLock invodations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a private method I wasn't sure if it is worth adding extra overloads (as then you have to document them as well :-))

@arhimondr
Copy link
Contributor Author

nit: is it possible to write a test?

Testing interrupt is usually painful. I don't think we have a test for the existing interruption logic.

@martint martint merged commit 0e9d17e into trinodb:master Feb 11, 2022
@github-actions github-actions bot added this to the 371 milestone Feb 11, 2022
@arhimondr arhimondr deleted the avoid-interrupting-jetty-threads branch February 14, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

trino-hive -P test-fault-tolerant-execution times out
6 participants