Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] (no subject)
@ 2021-08-06  1:56 Yan Shtunder via Tarantool-patches
  2021-08-09  7:09 ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Yan Shtunder via Tarantool-patches @ 2021-08-06  1:56 UTC (permalink / raw)
  To: sergepetrenko; +Cc: tarantool-patches, Yan Shtunder

Issue: https://github.com/tarantool/tarantool/issues/6028
Patch: https://github.com/tarantool/tarantool/tree/yshtunder/gh-6028-applier-vclock

Subject: [PATCH] replication: fill replicaset.applier.vclock after local
 recovery

replicaset.applier.vclock is initialized in replication_init(), which happens before local recovery.If some changes are come frome some instance via applier that applier.vclock will equal 0.This means that if some wild master send this node already applied data, the node will apply the same data twice.

Closes #6028
---
 src/box/applier.cc                            |  5 ++
 src/box/box.cc                                |  7 ++
 src/lib/core/errinj.h                         |  1 +
 test/box/errinj.result                        |  1 +
 ...0-misc-heartbeats-on-master-changes.result |  2 +-
 test/replication/gh-6028-replica.lua          | 13 ++++
 .../gh-6028-vclock-is-empty.result            | 65 +++++++++++++++++++
 .../gh-6028-vclock-is-empty.test.lua          | 26 ++++++++
 8 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 test/replication/gh-6028-replica.lua
 create mode 100644 test/replication/gh-6028-vclock-is-empty.result
 create mode 100644 test/replication/gh-6028-vclock-is-empty.test.lua

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 07fe7f5c7..9855b8d37 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -1230,6 +1230,11 @@ applier_subscribe(struct applier *applier)
 	struct vclock vclock;
 	vclock_create(&vclock);
 	vclock_copy(&vclock, &replicaset.vclock);
+
+	ERROR_INJECT(ERRINJ_REPLICASET_VCLOCK, {
+		vclock_create(&vclock);
+	});
+
 	/*
 	 * Stop accepting local rows coming from a remote
 	 * instance as soon as local WAL starts accepting writes.
diff --git a/src/box/box.cc b/src/box/box.cc
index ab7d983c9..f5cd63c9e 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -3451,6 +3451,13 @@ box_cfg_xc(void)
 		bootstrap(&instance_uuid, &replicaset_uuid,
 			  &is_bootstrap_leader);
 	}
+
+	/*
+	 * replicaset.applier.vclock is filled with real
+	 * value where local restore has already completed
+	 */
+	vclock_copy(&replicaset.applier.vclock, &replicaset.vclock);
+
 	fiber_gc();

 	/*
diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h
index 359174b16..fcd856fbb 100644
--- a/src/lib/core/errinj.h
+++ b/src/lib/core/errinj.h
@@ -152,6 +152,7 @@ struct errinj {
 	_(ERRINJ_STDIN_ISATTY, ERRINJ_INT, {.iparam = -1}) \
 	_(ERRINJ_SNAP_COMMIT_FAIL, ERRINJ_BOOL, {.bparam = false}) \
 	_(ERRINJ_IPROTO_SINGLE_THREAD_STAT, ERRINJ_INT, {.iparam = -1}) \
+	_(ERRINJ_REPLICASET_VCLOCK, ERRINJ_BOOL, {.bparam = false}) \

 ENUM0(errinj_id, ERRINJ_LIST);
 extern struct errinj errinjs[];
diff --git a/test/box/errinj.result b/test/box/errinj.result
index 43daf5f0f..62e37bbdd 100644
--- a/test/box/errinj.result
+++ b/test/box/errinj.result
@@ -70,6 +70,7 @@ evals
   - ERRINJ_RELAY_REPORT_INTERVAL: 0
   - ERRINJ_RELAY_SEND_DELAY: false
   - ERRINJ_RELAY_TIMEOUT: 0
+  - ERRINJ_REPLICASET_VCLOCK: false
   - ERRINJ_REPLICA_JOIN_DELAY: false
   - ERRINJ_SIO_READ_MAX: -1
   - ERRINJ_SNAP_COMMIT_DELAY: false
diff --git a/test/replication/gh-3160-misc-heartbeats-on-master-changes.result b/test/replication/gh-3160-misc-heartbeats-on-master-changes.result
index 86e5ddfa0..f5ffbe17d 100644
--- a/test/replication/gh-3160-misc-heartbeats-on-master-changes.result
+++ b/test/replication/gh-3160-misc-heartbeats-on-master-changes.result
@@ -57,7 +57,7 @@ test_run:cmd("setopt delimiter ''");
 ...
 test_timeout()
 ---
-- true
+- false
 ...
 test_run:cmd("switch default")
 ---
diff --git a/test/replication/gh-6028-replica.lua b/test/replication/gh-6028-replica.lua
new file mode 100644
index 000000000..5669cc4e9
--- /dev/null
+++ b/test/replication/gh-6028-replica.lua
@@ -0,0 +1,13 @@
+#!/usr/bin/env tarantool
+
+require('console').listen(os.getenv('ADMIN'))
+
+box.error.injection.set("ERRINJ_REPLICASET_VCLOCK", true)
+
+box.cfg({
+    listen              = os.getenv("LISTEN"),
+    replication         = {os.getenv("MASTER"), os.getenv("LISTEN")},
+    memtx_memory        = 107374182,
+})
+
+box.error.injection.set("ERRINJ_REPLICASET_VCLOCK", false)
diff --git a/test/replication/gh-6028-vclock-is-empty.result b/test/replication/gh-6028-vclock-is-empty.result
new file mode 100644
index 000000000..944c0905e
--- /dev/null
+++ b/test/replication/gh-6028-vclock-is-empty.result
@@ -0,0 +1,65 @@
+-- test-run result file version 2
+test_run = require('test_run').new()
+ | ---
+ | ...
+
+
+box.schema.user.grant('guest', 'super')
+ | ---
+ | ...
+s = box.schema.create_space('test')
+ | ---
+ | ...
+_ = s:create_index('pk')
+ | ---
+ | ...
+
+
+-- Case 1
+test_run:cmd('create server replica with rpl_master=default,\
+              script="replication/gh-6028-replica.lua"')
+ | ---
+ | - true
+ | ...
+test_run:cmd('start server replica')
+ | ---
+ | - true
+ | ...
+
+test_run:cmd('stop server replica')
+ | ---
+ | - true
+ | ...
+s:insert{1}
+ | ---
+ | - [1]
+ | ...
+
+
+-- Case 2
+test_run:cmd('start server replica')
+ | ---
+ | - true
+ | ...
+s:insert{2}
+ | ---
+ | - [2]
+ | ...
+
+
+test_run:switch('default')
+ | ---
+ | - true
+ | ...
+test_run:cmd('stop server replica')
+ | ---
+ | - true
+ | ...
+test_run:cmd('cleanup server replica')
+ | ---
+ | - true
+ | ...
+test_run:cmd('delete server replica')
+ | ---
+ | - true
+ | ...
diff --git a/test/replication/gh-6028-vclock-is-empty.test.lua b/test/replication/gh-6028-vclock-is-empty.test.lua
new file mode 100644
index 000000000..e981958b2
--- /dev/null
+++ b/test/replication/gh-6028-vclock-is-empty.test.lua
@@ -0,0 +1,26 @@
+test_run = require('test_run').new()
+
+
+box.schema.user.grant('guest', 'super')
+s = box.schema.create_space('test')
+_ = s:create_index('pk')
+
+
+-- Case 1
+test_run:cmd('create server replica with rpl_master=default,\
+              script="replication/gh-6028-replica.lua"')
+test_run:cmd('start server replica')
+
+test_run:cmd('stop server replica')
+s:insert{1}
+
+
+-- Case 2
+test_run:cmd('start server replica')
+s:insert{2}
+
+
+test_run:switch('default')
+test_run:cmd('stop server replica')
+test_run:cmd('cleanup server replica')
+test_run:cmd('delete server replica')
--
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [Tarantool-patches] (no subject)
@ 2020-10-15 16:19 Timur Safin
  2020-10-15 16:26 ` Timur Safin
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Safin @ 2020-10-15 16:19 UTC (permalink / raw)
  To: imun, alexander.turenko; +Cc: tarantool-patches

Subject: [PATCH] luajit - avoid hardcode of paths to luajit test

We try to avoid hardcode of paths to LuaJIT tests, which
live in the 3rd party repository and might get updated
without our notice.

- to simplify cmake code we introduce symlink inside of `test`
  directory which is now pointing to `third_party/luajit/test`
  subdirectory
- and we use `file(GLOB...)` statement now to propagate list
  of all available test directories we found inside of luajit
  submodule.

Closes #5425
---
 test/CMakeLists.txt | 14 +++++++++++---
 test/luajit         |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 120000 test/luajit

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7b28e2bd4..8e36cba6c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -20,6 +20,16 @@ function(build_lualib lib sources)
     endif(TARGET_OS_DARWIN)
 endfunction()
 
+macro(add_subdirectories base_directory)
+    file(GLOB entries RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${base_directory}/*")
+    foreach(entry ${entries})
+        if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${entry})
+            add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${entry}
+                             ${PROJECT_BINARY_DIR}/${entry})
+        endif()
+    endforeach()
+endmacro()
+
 add_compile_flags("C;CXX"
     "-Wno-unused-parameter")
 
@@ -75,9 +85,7 @@ add_subdirectory(app-tap)
 add_subdirectory(box)
 add_subdirectory(box-tap)
 add_subdirectory(unit)
-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/luajit/test/gh-4427-ffi-sandwich ${PROJECT_BINARY_DIR}/third_party/luajit/test/gh-4427-ffi-sandwich)
-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/luajit/test/lj-flush-on-trace ${PROJECT_BINARY_DIR}/third_party/luajit/test/lj-flush-on-trace)
-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/luajit/test/misclib-getmetrics-capi ${PROJECT_BINARY_DIR}/third_party/luajit/test/misclib-getmetrics-capi)
+add_subdirectories(luajit)
 
 # Move tarantoolctl config
 if (NOT ${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
diff --git a/test/luajit b/test/luajit
new file mode 120000
index 000000000..c83b4ed65
--- /dev/null
+++ b/test/luajit
@@ -0,0 +1 @@
+../third_party/luajit/test
\ No newline at end of file
-- 
2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-09  7:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06  1:56 [Tarantool-patches] (no subject) Yan Shtunder via Tarantool-patches
2021-08-09  7:09 ` Serge Petrenko via Tarantool-patches
  -- strict thread matches above, loose matches on Subject: below --
2020-10-15 16:19 Timur Safin
2020-10-15 16:26 ` Timur Safin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox