Skip to content

test: make the concurrent cancelation e2e test deterministic - #523

Merged
yarolegovich merged 2 commits into
mainfrom
yarolegovich/deflake-concurrent-cancel
Nov 4, 2026
Merged

yarolegovich merged 2 commits into
mainfrom
yarolegovich/deflake-concurrent-cancel

Conversation

@yarolegovich

Copy link
Copy Markdown
Member
  • The execution in TestConcurrentCancellation_ExecutionResolvesToCanceledTask starts writing artifacts only after CancelTask returned. Before, the cancelation raced with an artifact update every 5ms, and under -race and CPU load it lost all 10 optimistic concurrency retries once the task had grown to about 50–90 artifacts, because each attempt deep-copies the whole task twice.
  • The execution reports its context cause when its last write fails because the context was canceled. Before, the test then waited for the cause until the go test timeout.

With 32 parallel -race processes, the old test failed in 28 of 32 processes, and the new one passed 2,880 runs. Some of the lost-retry failures left the task FAILED, which is fixed in #522.

The cancelation raced with an artifact update every 5ms. Each retry
deep-copies the whole task twice, so under -race and CPU load the
cancelation lost all 10 retries once the task had grown to about 50-90
artifacts, and the test then hung until the client timeout. The
execution now starts writing artifacts after CancelTask returned.

The execution also reports its context cause when its last write fails
because the context was canceled. Before, the test then waited for the
cause until the go test timeout.
yarolegovich added a commit that referenced this pull request Nov 4, 2026
* When a cancelation loses every optimistic concurrency retry to a
concurrent execution, the processor no longer moves the task to
`FAILED`. The retry error wraps `taskstore.ErrConcurrentModification`
now, so `CancelTask` fails with that error and the task keeps running,
as for other concurrent modifications (#245).

This affects cancels handled by a server instance other than the one
running the execution, and every cancel in cluster mode. A cancel
handled by the instance running the execution goes through the
execution's pipe and doesn't race. Such a cancel can still lose every
retry when the store's read and update take longer than the interval
between the execution's updates, for example with a fast event stream
and a slow store. More attempts don't help in that case because the
conflicts are correlated, so fixing it needs a different way to signal
cancelation and is not part of this PR.

Found through the flaky
`TestConcurrentCancellation_ExecutionResolvesToCanceledTask`, which #523
makes deterministic.
@yarolegovich
yarolegovich merged commit f212299 into main Nov 4, 2026
5 checks passed
@yarolegovich
yarolegovich deleted the yarolegovich/deflake-concurrent-cancel branch November 4, 2026 14:28
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.

1 participant