-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix task failure signal race condition #15917
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
Changes from all commits
d6b7478
e90de23
414f8c8
3855afe
7a4f7c5
93e5561
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,8 +209,10 @@ public ListenableFuture<BufferResult> get(OutputBufferId bufferId, long token, D | |
| if (outputBuffer == null) { | ||
| synchronized (this) { | ||
| if (delegate == null) { | ||
| if (stateMachine.getState() == FINISHED) { | ||
| return immediateFuture(emptyResults(taskInstanceId, 0, true)); | ||
| if (stateMachine.getState().isTerminal()) { | ||
pettyjamesm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // only set complete when finished, otherwise | ||
| boolean complete = stateMachine.getState() == FINISHED; | ||
| return immediateFuture(emptyResults(taskInstanceId, 0, complete)); | ||
| } | ||
|
|
||
| PendingRead pendingRead = new PendingRead(bufferId, token, maxSize); | ||
|
|
@@ -310,19 +312,31 @@ public void destroy() | |
| @Override | ||
| public void abort() | ||
| { | ||
| List<PendingRead> pendingReads = ImmutableList.of(); | ||
| OutputBuffer outputBuffer = delegate; | ||
| if (outputBuffer == null) { | ||
| synchronized (this) { | ||
| if (delegate == null) { | ||
| // ignore abort if the buffer already in a terminal state. | ||
| stateMachine.abort(); | ||
| if (!stateMachine.abort()) { | ||
| return; | ||
| } | ||
|
|
||
| // Do not free readers on fail | ||
|
||
| return; | ||
| pendingReads = ImmutableList.copyOf(this.pendingReads); | ||
| this.pendingReads.clear(); | ||
| } | ||
| outputBuffer = delegate; | ||
| } | ||
| } | ||
|
|
||
| // if there is no output buffer, send an empty result without buffer completed signaled | ||
| if (outputBuffer == null) { | ||
| for (PendingRead pendingRead : pendingReads) { | ||
| pendingRead.getFutureResult().set(emptyResults(taskInstanceId, 0, false)); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| outputBuffer.abort(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move to a separate commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is all related code. The movement to here alone would cause issues with
scheduleDriversWithTaskLifecycle()not being called whentaskHandle == null. This is "fine" because it doesn't break the task state machine model today, but causes problems in a world with terminating task states.