Commit 163e45b
authored
Fix panic in defer after cache eviction. (#1048)
We have rather rare but annoying panic that hapens when workflow
contains certain api calls within a defer function. This only happens
when workflow is being blocked for some time and gets evicted from
the cache. At this point the dispatcher is being closed and all its
coroutines are exited with runtime.Goexit(). This in turn calls deffered
function. If user calls ExecuteActivity (among others) it receives
context that is no longer valid, since it is used not from within
ExecuteUntilAllBlocked loop. A safety check in getState is executed
which causes rather cryptic panic message: "illegal access from
outside of workflow context".
This panic is not harmful. Once unblocked workflow will be recreated
in the cache and replayed. When finished it will call its defer again
this time with a valid context. Nevertheless it is annoying an causes
confusion for the users.
The fix is rather simple. Within getState function, we check for closed
dispatcher. If it is the case we terminate current goroutine again with
runtime.GoExit() which prevent further execution of the defer.1 parent 0256258 commit 163e45b
2 files changed
+15
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
629 | 634 | | |
630 | 635 | | |
631 | 636 | | |
| |||
652 | 657 | | |
653 | 658 | | |
654 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
655 | 664 | | |
656 | 665 | | |
657 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
567 | 573 | | |
568 | 574 | | |
569 | 575 | | |
| |||
0 commit comments