Skip to content

fix TaskQueue-HRTR deadlock - #6212

Merged
gianm merged 2 commits into
apache:masterfrom
himanshug:fix_6201
Aug 25, 2018
Merged

gianm merged 2 commits into
apache:masterfrom
himanshug:fix_6201

Conversation

@himanshug

Copy link
Copy Markdown
Contributor

Fixes #6201

FWIW: RTR has same bug https://github.com/apache/incubator-druid/blob/master/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java#L908 but rarity of that happening causes getting into the deadlock very unlikely.

from the design perspective, to guarantee safety, I think it would eventually make more sense to make sure that all kinds of listeners are always executed in something other than SameThreadExecutor or that listeners are never called with internal locks being held as you don't know what listeners might end up doing.

TaskStatus taskStatus
)
{
Preconditions.checkArgument(!Thread.holdsLock(statusLock), "Current thread must not hold statusLock.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: checkState is more appropriate here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

makes sense, fixed

// on a worker - this avoids overflowing a worker with tasks
long waitMs = config.getTaskAssignmentTimeout().toStandardDuration().getMillis();
long waitStart = System.currentTimeMillis();
boolean isTaskAssignmentTimedout = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: isTaskAssignmentTimedOut (spelling: timed out is two words.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed :)

@gianm

gianm commented Aug 23, 2018

Copy link
Copy Markdown
Contributor

@himanshug,

from the design perspective, to guarantee safety, I think it would eventually make more sense to make sure that all kinds of listeners are always executed in something other than SameThreadExecutor or that listeners are never called with internal locks being held as you don't know what listeners might end up doing.

Probably the right thing to do is have the caller that sets a callback also pass an ExecutorService to use for that callback. That way the caller has some control over what thread pool to use, and the callee doesn't need to have its own callbacks thread pool that might never get used.

If it doesn't pass one in, then use a same-thread executor.

@gianm

gianm commented Aug 25, 2018

Copy link
Copy Markdown
Contributor

LGTM, thanks @himanshug

@gianm
gianm merged commit c3aaf81 into apache:master Aug 25, 2018
@gianm gianm modified the milestones: 0.12.3, 0.13.0 Aug 25, 2018
@gianm

gianm commented Aug 25, 2018

Copy link
Copy Markdown
Contributor

@himanshug, I moved this to 0.13, since 0.12 doesn't have the HTTP remote task runner.

gianm pushed a commit to implydata/druid-public that referenced this pull request Aug 25, 2018
* fix TaskQueue-HRTR deadlock causing apache#6201

* address review comments
@himanshug

Copy link
Copy Markdown
Contributor Author

@gianm sure, thanks.

riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
* fix TaskQueue-HRTR deadlock causing apache#6201

* address review comments
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