[Tarantool-patches] [PATCH v8 1/2] applier: filter incoming synchro packets via transaction initiator

Serge Petrenko sergepetrenko at tarantool.org
Tue Jun 15 14:35:16 MSK 2021



11.06.2021 18:22, Cyrill Gorcunov пишет:
> Currently we use synchro packets filtration based on their contents,
> in particular by their xrow->replica_id value. Still there was a
> question if we can optimize this moment and rather filter out all
> packets coming from non-leader replica.
>
> Raft specification requires that only data from a current leader
> should be applied to local WAL but doesn't put a concrete claim on
> the data transport, ie how exactly rows are reaching replicas. This
> implies that data propagation may reach replicas indirectly via transit
> hops. Thus we drop applier->instance_id filtering and rely on
> xrow->replica_id matching instead.
>
> In the test (inspired by Serge Petrenko's test) we recreate the situation
> where replica3 obtains master's node data (which is a raft leader)
> indirectly via replica2 node.
>
> Closes #6035
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>

I've found a way to make the test work as discussed: replication 1 <-> 2 
-> 3 from
the beginning. Without replication reconfiguration. Take a look at the 
diff below.

Although the diff doesn't simplify  anything, and it makes the test run 
longer: 2.5 s vs 0.8 s
on my machine. So it's up to you whether you want to apply it.

I'm starting to like your test version more, to be honest.


Here's the diff:
=================================================

diff --git a/test/replication/gh-6035-applier-filter.result 
b/test/replication/gh-6035-applier-filter.result
index 077cd46e5..4ddebcc6b 100644
--- a/test/replication/gh-6035-applier-filter.result
+++ b/test/replication/gh-6035-applier-filter.result
@@ -31,7 +31,7 @@ test_run:cmd('create server replica2 with 
script="replication/gh-6035-replica2.l
   | - true
   | ...

-test_run:cmd('start server master')
+test_run:cmd('start server master with wait=False')
   | ---
   | - true
   | ...
@@ -44,25 +44,24 @@ test_run:cmd('start server replica2')
   | - true
   | ...

-test_run:switch('replica2')
+--
+-- Make the master to be RAFT leader.
+test_run:switch('replica1')
   | ---
   | - true
   | ...
-box.cfg{replication = {require('fio').cwd() .. "/replica1.sock"}}
+box.cfg{election_mode = 'voter'}
   | ---
   | ...

---
--- Make the master to be RAFT leader.
  test_run:switch('master')
   | ---
   | - true
   | ...
+test_run:wait_lsn('master', 'replica1')
+ | ---
+ | ...
  box.cfg({                                               \
-    replication = {                                     \
-            require('fio').cwd() .. "/master.sock",     \
-            require('fio').cwd() .. "/replica1.sock",   \
-        },                                              \
      replication_synchro_quorum = 2,                     \
      election_mode = 'manual',                           \
  })
diff --git a/test/replication/gh-6035-applier-filter.test.lua 
b/test/replication/gh-6035-applier-filter.test.lua
index 4e72abe5f..4ec7a6e6a 100644
--- a/test/replication/gh-6035-applier-filter.test.lua
+++ b/test/replication/gh-6035-applier-filter.test.lua
@@ -19,21 +19,18 @@ test_run:cmd('create server master with 
script="replication/gh-6035-master.lua"'
  test_run:cmd('create server replica1 with 
script="replication/gh-6035-replica1.lua"')
  test_run:cmd('create server replica2 with 
script="replication/gh-6035-replica2.lua"')

-test_run:cmd('start server master')
+test_run:cmd('start server master with wait=False')
  test_run:cmd('start server replica1')
  test_run:cmd('start server replica2')

-test_run:switch('replica2')
-box.cfg{replication = {require('fio').cwd() .. "/replica1.sock"}}
-
  --
  -- Make the master to be RAFT leader.
+test_run:switch('replica1')
+box.cfg{election_mode = 'voter'}
+
  test_run:switch('master')
+test_run:wait_lsn('master', 'replica1')
  box.cfg({                                               \
-    replication = {                                     \
-            require('fio').cwd() .. "/master.sock",     \
-            require('fio').cwd() .. "/replica1.sock",   \
-        },                                              \
      replication_synchro_quorum = 2,                     \
      election_mode = 'manual',                           \
  })
diff --git a/test/replication/gh-6035-node.lua 
b/test/replication/gh-6035-node.lua
index e3819471a..4ed41b3cf 100644
--- a/test/replication/gh-6035-node.lua
+++ b/test/replication/gh-6035-node.lua
@@ -10,6 +10,10 @@ require('console').listen(os.getenv('ADMIN'))
  if INSTANCE_ID == "master" then
      box.cfg({
          listen = unix_socket("master"),
+        replication = {
+            unix_socket("master"),
+            unix_socket("replica1")
+        },
      })
  elseif INSTANCE_ID == "replica1" then
      box.cfg({
@@ -18,13 +22,12 @@ elseif INSTANCE_ID == "replica1" then
              unix_socket("master"),
              unix_socket("replica1")
          },
-        election_mode = 'voter'
      })
  else
      assert(INSTANCE_ID == "replica2")
      box.cfg({
          replication = {
-            unix_socket("master"),
+            unix_socket("replica1"),
          },
          election_mode = 'voter'
      })


====================================================

-- 
Serge Petrenko



More information about the Tarantool-patches mailing list