[PATCH v4 0/2] Make box.once() wait until instance enters rw mode

Vladimir Davydov vdavydov.dev at gmail.com
Sat Feb 10 19:48:58 MSK 2018


This patch set fixes box.once() failure in case the instance is
read-only. Now, instead of raising an error, it will wait until
the instance enters the read-write mode, provided, of course,
box.once() hasn't already been called for the same key, in which
case it returns immediately, as before. This should help
resolving box.once() replication conflicts in case the master is
in the read-write mode and the replica is read-only.

Patch 1 introduces two new Lua helpers, box.ctl.wait_ro() and
box.ctl_wait_rw(), which block the current fiber until the
server enters the read-only or read-write mode, respectively.
Patch 2 uses box.ctl.wait_rw() to fix box.once().

https://github.com/tarantool/tarantool/issues/2537
https://github.com/tarantool/tarantool/tree/box-once-wait-rw

Changes in v4:
 - box.info.wait_ro() => box.ctl.wait_ro(), box.ctl.wait_rw()
Changes in v3:
 - box.info.ro.wait() => box.info.wait_ro()
Changes in v2:
 - Introduce box.info.ro.wait() to wait for read-write mode and use
   it in box.once() instead of checking box.info.ro in a loop.

Vladimir Davydov (2):
  Add Lua helpers to wait for server to switch to/from ro mode
  Make box.once() wait until instance enters rw mode

 src/box/CMakeLists.txt         |   1 +
 src/box/box.cc                 |  21 ++++++++
 src/box/box.h                  |  10 ++++
 src/box/lua/ctl.c              |  78 ++++++++++++++++++++++++++++++
 src/box/lua/ctl.h              |  48 ++++++++++++++++++
 src/box/lua/init.c             |   2 +
 src/box/lua/schema.lua         |   1 +
 test/box/info.result           | 107 +++++++++++++++++++++++++++++++++++++++++
 test/box/info.test.lua         |  38 +++++++++++++++
 test/box/misc.result           |   1 +
 test/replication/once.result   |  48 ++++++++++++++++++
 test/replication/once.test.lua |  18 +++++++
 12 files changed, 373 insertions(+)
 create mode 100644 src/box/lua/ctl.c
 create mode 100644 src/box/lua/ctl.h

-- 
2.11.0




More information about the Tarantool-patches mailing list