forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wal: fix transaction boundaries for replicated transactions
Transaction boundaries were not updated correctly for transactions in which local space writes were made from a replication trigger. Existing transaction boundaries and row flags from the master were written as is on the replica. Actually, the replica should recalculate transaction boundaries and even WAIT_SYNC/WAIT_ACK flags. Transaction boundaries should be recalculated when a replica appends a local write at the end of the master's transaction, and WAIT_SYNC/WAIT_ACK should be overwritten when nopifying synchronous transactions coming from an old term. The latter fix has uncovered the bug in skipping outdated synchronous transactions: if one replica replaces a transaction from an old term with NOPs and then passes that transaction to the other replica, the other replica raises a split brain error. It believes the NOPs are an async transaction form an old term. This worked before the fix, because the rows were written with the original WAIT_ACK = true bit. Now this is fixed properly: we allow fully NOP async tranasctions from the old term. Closes tarantool#8746 NO_DOC=bugfix NO_CHANGELOG=covered by the next commit
- Loading branch information
1 parent
ae5964a
commit 0878c30
Showing
3 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/replication-luatest/gh_8746_replica_transaction_boundary_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local t = require('luatest') | ||
local server = require('luatest.server') | ||
local replica_set = require('luatest.replica_set') | ||
|
||
local g = t.group('gh-8746-transaction-boundaries') | ||
|
||
g.before_each(function(cg) | ||
cg.replica_set = replica_set:new{} | ||
end) | ||
|
||
g.after_each(function(cg) | ||
cg.replica_set:drop() | ||
end) | ||
|
||
local function prepare(cg) | ||
cg.replica_set:start() | ||
cg.master:exec(function() | ||
box.schema.space.create('test') | ||
box.space.test:create_index('pk') | ||
box.schema.space.create('loc', {is_local = true}) | ||
box.space.loc:create_index('pk') | ||
end) | ||
cg.replica:wait_for_vclock_of(cg.master) | ||
cg.replica:exec(function() | ||
box.space.test:on_replace(function(_, new) | ||
box.space.loc:replace(new) | ||
end) | ||
end) | ||
cg.master:exec(function() | ||
box.space.test:replace{1} | ||
end) | ||
cg.replica:wait_for_vclock_of(cg.master) | ||
end | ||
|
||
g.before_test('test_replica_recovery', function(cg) | ||
cg.master = cg.replica_set:build_and_add_server{ | ||
alias = 'master', | ||
box_cfg = { | ||
replication_timeout = 0.1, | ||
}, | ||
} | ||
cg.replica = cg.replica_set:build_and_add_server{ | ||
alias = 'replica', | ||
box_cfg = { | ||
read_only = true, | ||
replication = server.build_listen_uri('master', cg.replica_set.id), | ||
replication_timeout = 0.1, | ||
}, | ||
} | ||
end) | ||
|
||
g.test_replica_recovery = function(cg) | ||
prepare(cg) | ||
cg.replica:restart() | ||
cg.replica:wait_for_vclock_of(cg.master) | ||
end |