mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-29 20:57:00 +00:00
The test starts by waiting a certain number of ticks for the first node to elect itself as a leader. If this wait times out - i.e. the number of ticks passes before the node manages to elect itself - the future associated with the task which checks for the leader condition becomes discarded (it is passed to `with_timeout`) and the task may keep using the `environment` (which it has a reference to) even after the `environment` is destroyed. Furthermore, the aforementioned task is a coroutine which uses lambda captures in its body. Leaving `with_timeout` destroys the lambda object, causing the coroutine to refer to no-longer-existing captures. We fix the problems by: - making `environment` `weakly_referencable` and checking if its alive before it's used inside the task, - not capturing anything in the lambda but passing whatever's needed as function arguments (so these things get allocated inside the coroutine frame).