memtx: handle all statements related to the space on DDL
When DDL happens, we remove statements of concurrent transactions from MVCC. When removing statements, we set their `engine_savepoint` to `NULL` so that they won't be rolled back because we've already handled them. However, we remove statements only from stories, and not all statements can be accessed in this way. For example, when we have several delete statements of one story, and one of them gets prepared, others are unlinked. It leads to use-after-free, but it's read-only and doesn't affect anything, so only ASAN can catch it. It happens when the statement is being rolled back in `memtx_engine_rollback_statement`: we check if `space->upgrade` is not `NULL` (space can be already deleted) but this check affects instruction flow only if `stmt->new_tuple != NULL` and in our case that's not so. Anyway, let's iterate over all statements of all transactions and remove savepoints for ones related to the space that is being invalidated. It takes more time, but anyway, we are doing DDL that is heavy, so it doesn't really matter. Along the way, the commit removes helper `memtx_tx_history_remove_stmt` and all its helpers because they are not needed anymore. This helper unlinks added story from history chain, links all its delete statements to the previous story, if any, unlinks the statement from related stories and sets `engine_savepoint` to `NULL`. Since we already do all of this things except for unlinking statements from stories, let's simply call `memtx_tx_story_unlink_added[deleted]_by` instead. This change makes the code much more straightforward. Closes #10146 NO_DOC=bugfix (cherry picked from commit ac112b73192ad96271a02ee85dba3e9737fdaa9d)
Showing
- changelogs/unreleased/gh-10146-mvcc-ddl-crashes-and-isolation-violation.md 4 additions, 0 deletions...ased/gh-10146-mvcc-ddl-crashes-and-isolation-violation.md
- src/box/memtx_tx.c 20 additions, 109 deletionssrc/box/memtx_tx.c
- test/box-luatest/mvcc_ddl_test.lua 22 additions, 0 deletionstest/box-luatest/mvcc_ddl_test.lua
Loading
Please register or sign in to comment