box: allow to truncate temp and local spaces in ro mode
To achieve that, we bypass the read-only check for the _truncate system space in box_process1() and perform it in the on_replace system trigger instead, when we know which space is truncated. Note, we have to move the check for insertion of a new record into the _truncate system space before the read-only check in the on_replace trigger callback; this is needed for initial recovery with a non-empty _truncate space to work. While we are at it, let's use recovery_state to make the check explicit. Closes #5616 @TarantoolBot document Title: Mention that temp and local spaces can be truncated in ro mode DML operations on temporary and local spaces can be performed even if the instance is in the read-only mode, but DDL operations (such as `alter`) are forbidden in this case[^1]. Technically, `truncate` is a DDL operation so initially it was forbidden as well. However, it should be safe to perform this operation on a temporary or local space because logically it only modifies the data stored in the space (like DML) and it isn't replicated (see tarantool/tarantool#4263). So starting from Tarantool 2.11.1 we allow users to truncate temporary spaces in the read-only mode. [^1]: https://www.tarantool.io/en/doc/latest/concepts/replication/repl_architecture/#replication-local
Showing
- changelogs/unreleased/gh-5616-temp-space-truncate-ro.md 4 additions, 0 deletionschangelogs/unreleased/gh-5616-temp-space-truncate-ro.md
- src/box/alter.cc 17 additions, 10 deletionssrc/box/alter.cc
- src/box/box.cc 9 additions, 3 deletionssrc/box/box.cc
- src/box/box.h 7 additions, 0 deletionssrc/box/box.h
- test/box-luatest/gh_5616_temp_space_truncate_ro_test.lua 167 additions, 0 deletionstest/box-luatest/gh_5616_temp_space_truncate_ro_test.lua
- test/replication/anon.result 0 additions, 4 deletionstest/replication/anon.result
- test/replication/anon.test.lua 0 additions, 1 deletiontest/replication/anon.test.lua
Loading