vinyl: log new index before WAL write on DDL
Currently, we write new indexes to vylog only after successful WAL write (see vinyl_index_commit_create). This is incompatible with space ALTER - the problem is during ALTER vinyl may need to create new run files, which we need to track in order not to leave garbage if ALTER fails or tarantool exits before ALTER is complete. So this patch splits index creation in two stages, prepare and commit. The 'commit' stage is represented by existing VY_LOG_CREATE_LSM record, which is written from index_vtab::commit_create callback, just like before. For the 'prepare' stage we introduce a new record type, VY_LOG_REPARE_LSM, written from index_vtab::add_primary_key and index_vtab::build_index callbacks, i.e. before WAL write. For now, we don't write anything to prepared, but uncommitted indexes (this will be done later), but we do add prepared indexes to the scheduler so that they can be dumped and compacted. If ALTER fails, we drop prepared indexes in index_vtab::abort_create callback. Prepared but uncommitted indexes are ignored by backup and replication and cleaned up from vylog on restart. Note, we have to rework vinyl/errinj_vylog test in this patch, because index creation (and hence space truncation) commands now fail on vylog error, i.e. a situation when the same index is dropped and recreated multiple times in xlog without having corresponding records in vylog is now impossible. Also, space truncation is not linearizable for vinyl anymore as it may yield before WAL write, while trying to prepare an index in vylog. This is OK - we never promised it is. Remove the corresponding test case. Needed for #1653
Showing
- src/box/vinyl.c 52 additions, 23 deletionssrc/box/vinyl.c
- src/box/vy_log.c 154 additions, 17 deletionssrc/box/vy_log.c
- src/box/vy_log.h 44 additions, 7 deletionssrc/box/vy_log.h
- src/box/vy_lsm.c 55 additions, 25 deletionssrc/box/vy_lsm.c
- src/box/vy_lsm.h 2 additions, 2 deletionssrc/box/vy_lsm.h
- test/engine/truncate.result 0 additions, 87 deletionstest/engine/truncate.result
- test/engine/truncate.test.lua 0 additions, 48 deletionstest/engine/truncate.test.lua
- test/vinyl/errinj_vylog.result 80 additions, 89 deletionstest/vinyl/errinj_vylog.result
- test/vinyl/errinj_vylog.test.lua 51 additions, 61 deletionstest/vinyl/errinj_vylog.test.lua
Loading
Please register or sign in to comment