alter: commit old index drop and new index create on index rebuild
To rebuild an index when its key def changes, we effectively drop it and create a new index instead. Skipping Index::commitDrop and commitCreate stages at this point deprives Vinyl of an opportunity to log the change in the metadata log and replace the index in the scheduler, which leads to a crash. This patch adds the commit stage to RebuildIndex which calls the above-mentioned commitDrop and commitCreate for the old and the new indexes, respectively. There is a nuance here. Memtx piggybacks Index::commitDrop to drop space tuples when the primary index is dropped. This is actually wrong for tuples belong to a space, not to an index. Besides, it prevents us from just calling Index::commitDrop() from RebuildIndex::commit() as is, because RebuildIndex does not modify space data, it just moves space tuples to a new index. To circumvent this, let us remove commitDrop() method from MemtxIndex and drop space tuples directly from MemtxSpace's commitTruncateSpace() and commitAlterSpace().
Showing
- src/box/alter.cc 10 additions, 0 deletionssrc/box/alter.cc
- src/box/memtx_index.cc 0 additions, 13 deletionssrc/box/memtx_index.cc
- src/box/memtx_index.h 0 additions, 8 deletionssrc/box/memtx_index.h
- src/box/memtx_space.cc 24 additions, 3 deletionssrc/box/memtx_space.cc
- src/box/memtx_space.h 2 additions, 0 deletionssrc/box/memtx_space.h
- test/engine/truncate.result 5 additions, 2 deletionstest/engine/truncate.result
- test/engine/truncate.test.lua 3 additions, 2 deletionstest/engine/truncate.test.lua
- test/vinyl/ddl.result 44 additions, 1 deletiontest/vinyl/ddl.result
- test/vinyl/ddl.test.lua 13 additions, 1 deletiontest/vinyl/ddl.test.lua
Loading
Please register or sign in to comment