hot standby mode: fix broken read only mode during hot standby
Fix a bug when the server would enter read-write mode prematurely in hot standby mode, and let the script continue and try to create spaces/indexes. The bug is a regression introduced by the patch which changed cfg.listen to a dynamic option. This is an *incompatible* change: box.cfg{} used to return before binding to the primary port, this is no llonger the case. Always bind to the listen port in box.cfg{} call, not in the background, and leave local hot standby mode *before* leaving box.cfg{}. This avoids tons of tricky race conditions in user scripts when box.cfg{} has ended but the server is actually still read only. Except, thanks to another bug in box_set_cluster_id(), it wasn't really read-only, because box_set_cluster_id() would switch off read-only mode before local hot standby has ended (so a superposition of two bugs). The manifestation of this was as follows: Imagine the following script: box.cfg{listen = 3301} box.schema.space.create('tester') box.space.tester:create_index('primary') The server would start in local hot standby mode. Save a snapshot. Fall through to DDL. Then leave local hot standby and turn on WAL. The created space will end up not being in the write ahead log. The problem wasn't noticable in most cases, since the server could bind to the primary port quite quickly. Fix the test runner to detect a local hot standby server as started. Add a workaround for gh-721 until a complete patch is ready.
Showing
- src/box/box.cc 17 additions, 16 deletionssrc/box/box.cc
- src/box/cluster.cc 8 additions, 1 deletionsrc/box/cluster.cc
- src/box/iproto.cc 0 additions, 7 deletionssrc/box/iproto.cc
- src/box/recovery.cc 8 additions, 0 deletionssrc/box/recovery.cc
- src/box/recovery.h 4 additions, 0 deletionssrc/box/recovery.h
- src/coio.cc 19 additions, 0 deletionssrc/coio.cc
- src/coio.h 3 additions, 0 deletionssrc/coio.h
- test/lib/tarantool_server.py 5 additions, 3 deletionstest/lib/tarantool_server.py
- test/replication/hot_standby.lua 1 addition, 1 deletiontest/replication/hot_standby.lua
- test/replication/hot_standby.result 74 additions, 71 deletionstest/replication/hot_standby.result
- test/replication/hot_standby.test.lua 11 additions, 8 deletionstest/replication/hot_standby.test.lua
Loading
Please register or sign in to comment