vinyl: bypass format validation for statements loaded from disk
When the format of a space is altered, we walk over all tuples stored in the primary index and check them against the new format. This doesn't guarantee that all *statements* stored in the primary index conform to the new format though, because the check isn't performed for deleted or overwritten statements, e.g. s = box.schema.space.create('test', {engine = 'vinyl'}) s:create_index('primary') s:insert{1} box.snapshot() s:delete{1} -- The following command will succeed, because the space is empty, -- however one of the runs contains REPLACE{1}, which doesn't conform -- to the new format. s:create_index('secondary', {parts = {2, 'unsigned'}}) This is OK as we will never return such overwritten statements to the user, however we may still need to read them. Currently, this leads either to an assertion failure or to a read error in vy_stmt_decode vy_stmt_new_with_ops tuple_init_field_map We could probably force major compaction of the primary index to purge such statements, but it is complicated as there may be a read view preventing the write iterator from squashing such a statement, and currently there's no way to force destruction of a read view. So this patch simply disables format validation for all tuples loaded from disk (actually we already skip format validation for all secondary index statements and for DELETE statements in primary indexes so this isn't as bad as it may seem). To do that, it adds a boolean parameter to tuple_init_field_map() that disables format validation, and then makes vy_stmt_new_with_ops(), which is used for constructing vinyl statements, set it to false. This is OK as all statements inserted into a vinyl space are validated explicitly with tuple_validate() anyway. This is rather a workaround for the lack of a better solution. Closes #3540
Showing
- src/box/memtx_engine.c 1 addition, 1 deletionsrc/box/memtx_engine.c
- src/box/tuple.c 1 addition, 1 deletionsrc/box/tuple.c
- src/box/tuple_format.c 10 additions, 6 deletionssrc/box/tuple_format.c
- src/box/tuple_format.h 2 additions, 1 deletionsrc/box/tuple_format.h
- src/box/vy_stmt.c 18 additions, 5 deletionssrc/box/vy_stmt.c
- test/vinyl/ddl.result 39 additions, 0 deletionstest/vinyl/ddl.result
- test/vinyl/ddl.test.lua 15 additions, 0 deletionstest/vinyl/ddl.test.lua
Loading
Please register or sign in to comment