push
github
vinyl: fix space truncation being aborted by yield under load Under the hood, `space:truncate()` calls `space_vtab::build_index` to notify the engine about index recreation, see `TruncateIndex::prepare`. `space_vtab::build_index` isn't supposed to yield in this case because the space is empty (note that `TruncateIndex::prepare` passes the new space to the callback). However, there's a bug in vinyl that makes this callback yield for no good reason, aborting `space:truncate()` with `ER_TRANSACTION_YIELD`. The problem lies in `vy_tx_manager_abort_writers_for_ddl()`, which is called by `vinyl_space_build_index()` to abort all transactions that write to the target space. If a transaction can't be aborted because it has reached WAL, the function sets the `need_wal_sync` flag which indicates the caller that they should call `wal_sync()` to flush all unconfirmed transactions. In case of a space truncation, the function should do nothing because there can't possibly be a transaction writing to the new space, but actually it sets `need_wal_sync` if there's any transaction waiting for WAL. This mistake doesn't lead to any problems during an actual index build, but in case of a space truncation it results in the transaction being aborted by a fiber yield. Let's fix this problem by setting the `need_wal_sync` flag only if there are transactions that actually write to the target space. Closes #11249 NO_DOC=bug fix (cherry picked from commit b145c0c89)
63436 of 114770 branches covered (55.27%)
6 of 6 new or added lines in 1 file covered. (100.0%)
21 existing lines in 9 files now uncovered.94403 of 109663 relevant lines covered (86.08%)
3290558.92 hits per line