alter: wait for previous alters to commit on DDL
Yielding DDL operations acquire DDL lock so that the space cannot be modified under its feet. However, there is a case when it actually can: if a yielding DDL has started when there is another DDL is being committed and it gets rolled back due to WAL error, `struct space` created by rolled back DDL is deleted - and it's the space being altered by the yielding DDL. In order to fix this problem, let's simply wait for all previous alters to be committed. We could use `wal_sync` to wait for all previous transactions to be committed, but it is more complicated - we need to use `wal_sync` for single instance and `txn_limbo_wait_last_txn` when the limbo queue has an owner. Such approach has more pitfalls and requires more tests to cover all cases. When relying on `struct alter_space` directly, all situations are handled with the same logic. Alternative solutions that we have tried: 1. Throw an error in the case when user tries to alter space when there is another non-committed alter. Such approach breaks applier since it applies rows asynchronously. Trying applier to execute operations synchronously breaks it even harder. 2. Do not use space in `build_index` and `check_format` methods. In this case, there is another problem: rollback order. We have to rollback previous alters firstly, and the in-progress one can be rolled back only after it's over. It breaks fundamental memtx invariant: rollback order must be reverse of replace order. We could try to use `before_replace` triggers for alter, but the patch would be bulky. Closes #10235 NO_DOC=bugfix (cherry picked from commit fee8c5dd6b16471739ed8512ba4137ff2e7274aa)
Showing
- changelogs/unreleased/gh-10235-consequent-ddl-crash.md 4 additions, 0 deletionschangelogs/unreleased/gh-10235-consequent-ddl-crash.md
- src/box/alter.cc 73 additions, 12 deletionssrc/box/alter.cc
- test/engine-luatest/gh_10235_crash_on_consequent_ddl_test.lua 43 additions, 0 deletions.../engine-luatest/gh_10235_crash_on_consequent_ddl_test.lua
Loading
Please register or sign in to comment