replication: set replica ID before _cluster commit
Replica registration works via looking for the smallest not occupied ID in _cluster and inserting it into the space. It works not so good when mvcc is enabled. In particular, if more than 1 replica try to register at the same time, they might get the same replica_id because don't see changes of each other until the registration in _cluster is complete. This in the end leads to all replicas failing the registration except one with the 'duplicate key' error (primary index in _cluster is replica ID). The patch makes the replicas occupy their ID before they commit it into _cluster. And new replica ID search now uses the replica ID map instead of _cluster iterator. This way the registration works like before - like MVCC does not exist which is fine. Closes #5601
Showing
- changelogs/unreleased/gh-5601-cluster-mvcc-duplicate.md 7 additions, 0 deletionschangelogs/unreleased/gh-5601-cluster-mvcc-duplicate.md
- src/box/alter.cc 64 additions, 49 deletionssrc/box/alter.cc
- src/box/box.cc 3 additions, 16 deletionssrc/box/box.cc
- src/box/replication.cc 13 additions, 0 deletionssrc/box/replication.cc
- src/box/replication.h 4 additions, 0 deletionssrc/box/replication.h
- test/replication/gh-5430-cluster-mvcc.result 146 additions, 0 deletionstest/replication/gh-5430-cluster-mvcc.result
- test/replication/gh-5430-cluster-mvcc.test.lua 62 additions, 0 deletionstest/replication/gh-5430-cluster-mvcc.test.lua
- test/replication/gh-5430-mvcc-master.lua 11 additions, 0 deletionstest/replication/gh-5430-mvcc-master.lua
- test/replication/gh-5430-mvcc-replica1.lua 10 additions, 0 deletionstest/replication/gh-5430-mvcc-replica1.lua
- test/replication/gh-5430-mvcc-replica2.lua 1 addition, 0 deletionstest/replication/gh-5430-mvcc-replica2.lua
- test/replication/suite.cfg 1 addition, 0 deletionstest/replication/suite.cfg
- test/replication/suite.ini 1 addition, 1 deletiontest/replication/suite.ini
Loading
Please register or sign in to comment