core: fix crashes after altering trigger list while it is run
This patch fixes a number of issues with trigger_clear() while the trigger list is being run: 1) clearing the next-to-be-run trigger doesn't prevent it from being run 2) clearing the next-to-be-run trigger causes an infinite loop or a crash 3) swapping trigger list head before the last trigger is run causes an infinite loop or a crash (see space_swap_triggers() in alter.cc, which had worked all this time by miracle: space _space on_replace trigger swaps its own head during local recovery, and that had only worked because the trigger by luck was the last to run) This is fixed by adding triggers in a separate run list on trigger_run. This list may be iterated by `rlist_shift_entry`, which doesn't suffer from any of the problems mentioned above. While being bad in a number of ways, old approach supported practically unlimited number of concurrent trigger_runs for the same trigger list. The new approach requires the trigger to be in as many run lists as there are concurrent trigger_runs, which results in quite a big refactoring. Add a luatest-based test and a unit test. Closes #4264 NO_DOC=bugfix
Showing
- changelogs/unreleased/gh-4264-trigger-crash-on-nontrivial-change.md 4 additions, 0 deletions.../unreleased/gh-4264-trigger-crash-on-nontrivial-change.md
- src/lib/core/fiber.c 2 additions, 0 deletionssrc/lib/core/fiber.c
- src/lib/core/trigger.cc 138 additions, 12 deletionssrc/lib/core/trigger.cc
- src/lib/core/trigger.h 18 additions, 8 deletionssrc/lib/core/trigger.h
- test/box-luatest/gh_4264_recursive_trigger_test.lua 64 additions, 0 deletionstest/box-luatest/gh_4264_recursive_trigger_test.lua
- test/unit/CMakeLists.txt 2 additions, 0 deletionstest/unit/CMakeLists.txt
- test/unit/trigger.c 202 additions, 0 deletionstest/unit/trigger.c
Loading
Please register or sign in to comment