Fix abortion for injected tasks#516
Conversation
If tasks were injected after the change was aborted, it results in a deadlock between the tasks that would wait for the parent to finish and the parent that would wait for the children to undo.
be83aff to
c6b693e
Compare
jonathan-conder
left a comment
There was a problem hiding this comment.
I don't have the expertise to know if this is the best approach, but it makes sense to me. Will be interesting to see what the Snap team says
TICS Quality Gate✔️ PassedworkshopAll conditions passedSee the results in the TICS Viewer The following files have been checked for this project
|
|
I need to have a look at this in snapd. Was discussed here previously: https://chat.canonical.com/canonical/pl/g4dfeqnsqfbu9x74t7x6enbkxh |
|
The test you added does not seem to actually exercise the bug. If I back out the code changes but leave the test changes, it still passes. This is on master: |
|
I opened a PR against snapd to backport this change, but we should make sure the tests exercise the fix before progressing there: canonical/snapd#16235 |
|
I think this change will make it exercise the fix. I'll wait for Dmitry to confirm though, I never went in depth on understanding this one. diff --git a/internal/overlord/handlersetup/handler_setup_test.go b/internal/overlord/handlersetup/handler_setup_test.go
index 64e73f19..e4e933d3 100644
--- a/internal/overlord/handlersetup/handler_setup_test.go
+++ b/internal/overlord/handlersetup/handler_setup_test.go
@@ -158,14 +158,14 @@ func (s *CommonStateFuncs) TestInjectTasksMainAborted(c *check.C) {
t0.SetStatus(state.DoingStatus)
chg.AddTask(t0)
t0.JoinLane(lane)
+ // This will abort the main task.
+ chg.Abort()
t01 := s.state.NewTask("task1-1", "")
t01.WaitFor(t0)
t02 := s.state.NewTask("task1-2", "")
t02.WaitFor(t0)
ts := state.NewTaskSet(t01, t02)
- // This will abort the main task.
- chg.Abort()
handlersetup.InjectTasks(t0, ts)
// verify that extra tasks are on holdThe reason the test passes without the fix is this section of workshop/internal/overlord/state/change.go Lines 788 to 792 in 2a07e43 |
Thanks for this! The issue is that Please see the fix here: https://github.com/canonical/workshop/pull/527/files |
Description
If tasks were injected after the change was aborted, it results in a deadlock between the
tasks that would wait for the parent to finish and the parent that would wait for the children to
undo.
Self-review quick check
Docs
Or: