vinyl: allow to modify key definition if it does not require rebuild
To allow extending key definition for non-empty vinyl spaces, this patch performs the following steps: - Revert commit c31dd19a ("vinyl: forbid vinyl index key definition alter") that forbade any key def alter. It isn't needed anymore. - Update key_def and cmp_def in vinyl_space_swap_index(). We simply swap the definitions between the old and new indexes in memory. Since all vinyl objects reference either vy_lsm::key_def or vy_lsm::cmp_def or both, and the change is compatible (does not change the order for existing tuples), this should work just fine. - Update key definition in vylog on ALTER. For this, we introduce a new vylog record type, VY_LOG_MODIFY_LSM, which updates key definition. To be able to replay it on recovery in case we failed to flush it before restart, we also store the LSN of the WAL record that triggered the ALTER. It also adds the following test cases: - Modify key definition of primary and secondary indexes of a non-empty space (engine/ddl). - Modify key definition before snapshot and relay it to a newly joined replica (engine/replica_join). - Make sure key definition is updated in vylog on ALTER (vinyl/layout).
Showing
- src/box/key_def.cc 9 additions, 0 deletionssrc/box/key_def.cc
- src/box/key_def.h 7 additions, 0 deletionssrc/box/key_def.h
- src/box/vinyl.c 41 additions, 23 deletionssrc/box/vinyl.c
- src/box/vy_log.c 75 additions, 4 deletionssrc/box/vy_log.c
- src/box/vy_log.h 22 additions, 0 deletionssrc/box/vy_log.h
- src/box/vy_lsm.c 3 additions, 2 deletionssrc/box/vy_lsm.c
- src/box/vy_lsm.h 6 additions, 4 deletionssrc/box/vy_lsm.h
- test/engine/ddl.result 110 additions, 3 deletionstest/engine/ddl.result
- test/engine/ddl.test.lua 34 additions, 1 deletiontest/engine/ddl.test.lua
- test/engine/replica_join.result 24 additions, 2 deletionstest/engine/replica_join.result
- test/engine/replica_join.test.lua 2 additions, 0 deletionstest/engine/replica_join.test.lua
- test/engine/truncate.result 1 addition, 1 deletiontest/engine/truncate.result
- test/engine/truncate.test.lua 1 addition, 1 deletiontest/engine/truncate.test.lua
- test/vinyl/ddl.result 21 additions, 57 deletionstest/vinyl/ddl.result
- test/vinyl/ddl.test.lua 7 additions, 23 deletionstest/vinyl/ddl.test.lua
- test/vinyl/gh.result 1 addition, 1 deletiontest/vinyl/gh.result
- test/vinyl/layout.result 35 additions, 32 deletionstest/vinyl/layout.result
- test/vinyl/layout.test.lua 3 additions, 1 deletiontest/vinyl/layout.test.lua
Loading
Please register or sign in to comment