-
Notifications
You must be signed in to change notification settings - Fork 53
api: fix INIT
state stuck
#227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,97 @@ | ||
#!/usr/bin/env tarantool | ||
|
||
local test = require('tap').test('') | ||
local queue = require('queue') | ||
local tnt = require('t.tnt') | ||
local fio = require('fio') | ||
local fiber = require('fiber') | ||
|
||
rawset(_G, 'queue', require('queue')) | ||
|
||
local qc = require('queue.compat') | ||
if not qc.check_version({2, 10, 0}) then | ||
require('log').info('Tests skipped, tarantool version < 2.10.0 ' .. | ||
'does not support the lazy init') | ||
return | ||
end | ||
|
||
local snapdir_optname = qc.snapdir_optname | ||
local logger_optname = qc.logger_optname | ||
|
||
test:plan(1) | ||
|
||
test:test('Check orphan mode not stalling queue', function(test) | ||
test:plan(4) | ||
local engine = os.getenv('ENGINE') or 'memtx' | ||
tnt.cluster.cfg{} | ||
|
||
local dir_replica = fio.tempdir() | ||
local cmd_replica = { | ||
arg[-1], | ||
'-e', | ||
[[ | ||
box.cfg { | ||
replication = { | ||
'replicator:[email protected]:3399', | ||
'replicator:[email protected]:3398', | ||
}, | ||
listen = '127.0.0.1:3396', | ||
wal_dir = ']] .. dir_replica .. '\'' .. | ||
',' .. snapdir_optname() .. ' = \'' .. dir_replica .. '\'' .. | ||
',' .. logger_optname() .. ' = \'' .. | ||
fio.pathjoin(dir_replica, 'tarantool.log') .. '\'' .. | ||
'}' | ||
} | ||
|
||
replica = require('popen').new(cmd_replica, { | ||
stdin = 'devnull', | ||
stdout = 'devnull', | ||
stderr = 'devnull', | ||
}) | ||
|
||
local attempts = 0 | ||
-- Wait for replica to connect. | ||
while box.info.replication[3] == nil or | ||
box.info.replication[3].downstream.status ~= 'follow' do | ||
|
||
attempts = attempts + 1 | ||
if attempts == 30 then | ||
error('wait for replica connection') | ||
end | ||
fiber.sleep(0.1) | ||
end | ||
|
||
local conn = require('net.box').connect('127.0.0.1:3396') | ||
|
||
conn:eval([[ | ||
box.cfg{ | ||
replication = { | ||
'replicator:[email protected]:3399', | ||
'replicator:[email protected]:3398', | ||
'replicator:[email protected]:3396', | ||
}, | ||
listen = '127.0.0.1:3397', | ||
replication_connect_quorum = 4, | ||
} | ||
]]) | ||
|
||
conn:eval('rawset(_G, "queue", require("queue"))') | ||
|
||
test:is(conn:call('queue.state'), 'INIT', 'check queue state') | ||
test:is(conn:call('box.info').ro, true, 'check read only') | ||
test:is(conn:call('box.info').ro_reason, 'orphan', 'check ro reason') | ||
|
||
conn:eval('box.cfg{replication_connect_quorum = 2}') | ||
|
||
local attempts = 0 | ||
while conn:call('queue.state') ~= 'RUNNING' and attempts < 50 do | ||
fiber.sleep(0.1) | ||
attempts = attempts + 1 | ||
end | ||
test:is(conn:call('queue.state'), 'RUNNING', 'check queue state after orphan') | ||
end) | ||
|
||
rawset(_G, 'queue', nil) | ||
tnt.finish() | ||
os.exit(test:check() and 0 or 1) | ||
-- vim: set ft=lua : |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.