Skip to content

Conversation

@zsxwing
Copy link
Member

@zsxwing zsxwing commented Mar 25, 2016

What changes were proposed in this pull request?

Extract the workaround for HADOOP-10622 introduced by #11940 into UninterruptibleThread so that we can test and reuse it.

How was this patch tested?

Unit tests

Extract the workaround for HADOOP-10622 introduced by #11940 into UninterruptibleThread so that we can test and reuse it.
@vanzin
Copy link
Contributor

vanzin commented Mar 26, 2016

LGTM but I wonder if just overriding Thread.run and making it final wouldn't be enough (the task to run would have to be passed as a Runnable). It would simplify the code a little bit and you wouldn't need to deal with reentrant calls, which the current code doesn't seem to need anyway.

@SparkQA
Copy link

SparkQA commented Mar 26, 2016

Test build #54235 has finished for PR 11971 at commit 8a65a9d.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@zsxwing
Copy link
Member Author

zsxwing commented Mar 26, 2016

LGTM but I wonder if just overriding Thread.run and making it final wouldn't be enough (the task to run would have to be passed as a Runnable). It would simplify the code a little bit and you wouldn't need to deal with reentrant calls, which the current code doesn't seem to need anyway.

Could you clarify it? If overriding run, then the whole Thread will be uninterruptible and this is not what we want.

@zsxwing
Copy link
Member Author

zsxwing commented Mar 26, 2016

retest this please

@SparkQA
Copy link

SparkQA commented Mar 26, 2016

Test build #54250 has finished for PR 11971 at commit 8a65a9d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor

vanzin commented Mar 27, 2016

Yes, my suggestion would make the whole thread uninterruptible. But from the only use case, it seems that would be ok - there are no calls I see that can be interrupted outside of the calls to runUninterrubptibly.

In any case, not a huge deal.

throw new IllegalStateException(s"Call runUninterruptibly in a wrong thread. " +
s"Expected: $this but was ${Thread.currentThread()}")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

minor: should you bail out early if shouldInterruptThread has already been set somehow?

Copy link
Member Author

Choose a reason for hiding this comment

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

minor: should you bail out early if shouldInterruptThread has already been set somehow?

Don't get it. shouldInterruptThread is just a flag that indicates if we should call super.interrupt in finally. What do you suggest to do here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean: if the thread is already interrupted before you try to run the given function (or, in other words, if Thread.interrupt() was called before you get to this point), should you just return early instead of calling the function?

(I guess I should have commented on L68 instead, where there's an explicit check for whether the thread is already interrupted.)

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, it should clear the interrupt status and set it back after calling f. StreamExecution allows people to interrupt at any time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that's what the code does right now. I'm asking whether it would be better to not run f if the thread has already been interrupted, since you might be running a long computation after some other code has asked the thread to stop what it's doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. Will update my PR.

@SparkQA
Copy link

SparkQA commented Mar 28, 2016

Test build #54335 has finished for PR 11971 at commit 47187d8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor

vanzin commented Mar 28, 2016

LGTM, merging to master.

@asfgit asfgit closed this in 2f98ee6 Mar 28, 2016
@zsxwing zsxwing deleted the uninterrupt branch March 28, 2016 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants