Skip to content

Ensure that for abort only abort is called

Kamil Trzciński requested to merge fix-cancel-handling into master

What does this MR do?

Previously we would call cancel() on abort() which in some implementations could result in calling additional steps due to race condition.

The abort() is final, we don't need to cancel() before as abort() in any case should take a precedence in processing.

Trigger race

The race condition can be triggered with:

diff --git a/common/build.go b/common/build.go
index 780ebee68..e62057134 100644
--- a/common/build.go
+++ b/common/build.go
@@ -663,6 +663,7 @@ func (b *Build) run(ctx context.Context, trace JobTrace, executor Executor) (err
        b.Log().Debugln("Waiting for signals...")
        select {
        case <-ctx.Done():
+               time.Sleep(2 * time.Second)
                err = b.handleError(ctx.Err())
 
        case signal := <-b.SystemInterrupt:

What are the relevant issue numbers?

Closes #27056 (closed)

Edited by Kamil Trzciński

Merge request reports