Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
b9fd0b3b
Commit
b9fd0b3b
authored
6 years ago
by
Vladimir Davydov
Browse files
Options
Downloads
Plain Diff
Merge branch '1.9' into 1.10
parents
ea69a0cd
ea28a925
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/box/replication.cc
+23
-0
23 additions, 0 deletions
src/box/replication.cc
test/replication/gc.result
+83
-0
83 additions, 0 deletions
test/replication/gc.result
test/replication/gc.test.lua
+36
-0
36 additions, 0 deletions
test/replication/gc.test.lua
with
142 additions
and
0 deletions
src/box/replication.cc
+
23
−
0
View file @
b9fd0b3b
...
...
@@ -206,6 +206,19 @@ replica_clear_id(struct replica *replica)
*/
replicaset
.
replica_by_id
[
replica
->
id
]
=
NULL
;
replica
->
id
=
REPLICA_ID_NIL
;
/*
* The replica will never resubscribe so we don't need to keep
* WALs for it anymore. Unregister it with the garbage collector
* if the relay thread is stopped. In case the relay thread is
* still running, it may need to access replica->gc so leave the
* job to replica_on_relay_stop, which will be called as soon as
* the relay thread exits.
*/
if
(
replica
->
gc
!=
NULL
&&
relay_get_state
(
replica
->
relay
)
!=
RELAY_FOLLOW
)
{
gc_consumer_unregister
(
replica
->
gc
);
replica
->
gc
=
NULL
;
}
if
(
replica_is_orphan
(
replica
))
{
replica_hash_remove
(
&
replicaset
.
hash
,
replica
);
replica_delete
(
replica
);
...
...
@@ -759,6 +772,16 @@ replicaset_check_quorum(void)
void
replica_on_relay_stop
(
struct
replica
*
replica
)
{
/*
* If the replica was evicted from the cluster, we don't
* need to keep WALs for it anymore. Unregister it with
* the garbage collector then. See also replica_clear_id.
*/
assert
(
replica
->
gc
!=
NULL
);
if
(
replica
->
id
==
REPLICA_ID_NIL
)
{
gc_consumer_unregister
(
replica
->
gc
);
replica
->
gc
=
NULL
;
}
if
(
replica_is_orphan
(
replica
))
{
replica_hash_remove
(
&
replicaset
.
hash
,
replica
);
replica_delete
(
replica
);
...
...
This diff is collapsed.
Click to expand it.
test/replication/gc.result
+
83
−
0
View file @
b9fd0b3b
...
...
@@ -369,6 +369,89 @@ replica_set.wait_all(test_run)
replica_set.drop_all(test_run)
---
...
--
-- Check that once a replica is removed from the cluster table,
-- all xlogs kept for it are removed even if it is configured as
-- a replication master (gh-3546).
--
fio = require('fio')
---
...
fiber = require('fiber')
---
...
-- Start a replica and set it up as a master for this instance.
test_run:cmd("start server replica")
---
- true
...
replica_port = test_run:eval('replica', 'return box.cfg.listen')[1]
---
...
replica_port ~= nil
---
- true
...
box.cfg{replication = replica_port}
---
...
-- Stop the replica and write a few WALs.
test_run:cmd("stop server replica")
---
- true
...
test_run:cmd("cleanup server replica")
---
- true
...
_ = s:auto_increment{}
---
...
box.snapshot()
---
- ok
...
_ = s:auto_increment{}
---
...
box.snapshot()
---
- ok
...
_ = s:auto_increment{}
---
...
box.snapshot()
---
- ok
...
#fio.glob('./master/*.xlog') == 3 or fio.listdir('./master')
---
- true
...
-- Delete the replica from the cluster table and check that
-- all xlog files are removed.
test_run:cleanup_cluster()
---
...
box.snapshot()
---
- ok
...
t = fiber.time()
---
...
while #fio.glob('./master/*xlog') > 0 and fiber.time() - t < 10 do fiber.sleep(0.01) end
---
...
#fio.glob('./master/*.xlog') == 0 or fio.listdir('./master')
---
- true
...
-- Restore the config.
box.cfg{replication = {}}
---
...
-- Cleanup.
s:drop()
---
...
...
This diff is collapsed.
Click to expand it.
test/replication/gc.test.lua
+
36
−
0
View file @
b9fd0b3b
...
...
@@ -172,6 +172,42 @@ replica_set.start_all(test_run)
replica_set
.
wait_all
(
test_run
)
replica_set
.
drop_all
(
test_run
)
--
-- Check that once a replica is removed from the cluster table,
-- all xlogs kept for it are removed even if it is configured as
-- a replication master (gh-3546).
--
fio
=
require
(
'fio'
)
fiber
=
require
(
'fiber'
)
-- Start a replica and set it up as a master for this instance.
test_run
:
cmd
(
"start server replica"
)
replica_port
=
test_run
:
eval
(
'replica'
,
'return box.cfg.listen'
)[
1
]
replica_port
~=
nil
box
.
cfg
{
replication
=
replica_port
}
-- Stop the replica and write a few WALs.
test_run
:
cmd
(
"stop server replica"
)
test_run
:
cmd
(
"cleanup server replica"
)
_
=
s
:
auto_increment
{}
box
.
snapshot
()
_
=
s
:
auto_increment
{}
box
.
snapshot
()
_
=
s
:
auto_increment
{}
box
.
snapshot
()
#
fio
.
glob
(
'./master/*.xlog'
)
==
3
or
fio
.
listdir
(
'./master'
)
-- Delete the replica from the cluster table and check that
-- all xlog files are removed.
test_run
:
cleanup_cluster
()
box
.
snapshot
()
t
=
fiber
.
time
()
while
#
fio
.
glob
(
'./master/*xlog'
)
>
0
and
fiber
.
time
()
-
t
<
10
do
fiber
.
sleep
(
0
.
01
)
end
#
fio
.
glob
(
'./master/*.xlog'
)
==
0
or
fio
.
listdir
(
'./master'
)
-- Restore the config.
box
.
cfg
{
replication
=
{}}
-- Cleanup.
s
:
drop
()
box
.
error
.
injection
.
set
(
"ERRINJ_RELAY_REPORT_INTERVAL"
,
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment