From a4d641b215bbec991854b04a656561abd7190ddd Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 21:47:14 +0000 Subject: [PATCH 1/5] Ensure ev abandon_watcher is stopped before reuse. --- src/server/mirror.c | 1 + .../acceptance/test_write_during_migration.rb | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/server/mirror.c b/src/server/mirror.c index b1d917b..75bf3f5 100644 --- a/src/server/mirror.c +++ b/src/server/mirror.c @@ -671,6 +671,7 @@ static void mirror_abandon_cb(struct ev_loop *loop, ev_io * w, int revents) debug("Abandon message received"); mirror_set_state(ctrl->mirror, MS_ABANDONED); self_pipe_signal_clear(ctrl->mirror->abandon_signal); + ev_io_stop(loop, &ctrl->abandon_watcher); ev_break(loop, EVBREAK_ONE); return; } diff --git a/tests/acceptance/test_write_during_migration.rb b/tests/acceptance/test_write_during_migration.rb index 70ef9e6..bbe41ff 100755 --- a/tests/acceptance/test_write_during_migration.rb +++ b/tests/acceptance/test_write_during_migration.rb @@ -86,6 +86,14 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end + def stop_mirror + UNIXSocket.open(@source_sock) do |sock| + sock.write("break\x0A\x0A") + sock.flush + sock.readline + end + end + def wait_for_quit Timeout.timeout(10) do Process.waitpid2(@dst_proc) @@ -195,4 +203,22 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end end + + def test_mirroring_can_be_restarted + Dir.mktmpdir do |tmpdir| + Dir.chdir(tmpdir) do + make_files + + launch_servers + + 3.times do + start_mirror + stop_mirror + end + start_mirror + + wait_for_quit + end + end + end end From 52690f5382491514c3f854e8dc32e8bfbe44d31a Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 21:48:55 +0000 Subject: [PATCH 2/5] Updated changelog --- debian/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/changelog b/debian/changelog index e79dead..0f632cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ flexnbd (0.4.0) UNRELEASED; urgency=medium * Explicitly close the server control socket, and wait for it to close, to prevent deadlocks during the server clean-up process (#40 !58) + * Ensure mirroring can be restarted after a break command is sent to the + source (#38, !59) -- Patrick J Cherry Fri, 07 Dec 2018 16:38:56 +0000 From 39400f2e09d933b73349abcea43bf93ec39760c0 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 21:50:56 +0000 Subject: [PATCH 3/5] Fixed issue number. --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0f632cf..6c33cdc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,7 +3,7 @@ flexnbd (0.4.0) UNRELEASED; urgency=medium * Explicitly close the server control socket, and wait for it to close, to prevent deadlocks during the server clean-up process (#40 !58) * Ensure mirroring can be restarted after a break command is sent to the - source (#38, !59) + source (#37, !59) -- Patrick J Cherry Fri, 07 Dec 2018 16:38:56 +0000 From e5133a50bdf05eac2f26393c9c574ab9568fe033 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 22:09:21 +0000 Subject: [PATCH 4/5] Slow down start/stop. Enable DEBUG Trying to working why this is failing in gitlab-ci --- tests/acceptance/test_write_during_migration.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/test_write_during_migration.rb b/tests/acceptance/test_write_during_migration.rb index bbe41ff..83cc6d1 100755 --- a/tests/acceptance/test_write_during_migration.rb +++ b/tests/acceptance/test_write_during_migration.rb @@ -185,7 +185,6 @@ class TestWriteDuringMigration < Test::Unit::TestCase end end - def test_status_call_after_cleanup Dir.mktmpdir do |tmpdir| Dir.chdir(tmpdir) do @@ -209,11 +208,15 @@ class TestWriteDuringMigration < Test::Unit::TestCase Dir.chdir(tmpdir) do make_files + ENV['DEBUG'] = '1' launch_servers + ENV.delete 'DEBUG' 3.times do start_mirror + sleep 0.1 stop_mirror + sleep 0.1 end start_mirror From 6b1a877dc3f6b29ab02eeb2ab306098647d3d946 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 7 Dec 2018 22:43:50 +0000 Subject: [PATCH 5/5] Tweaked test file size, and removed debug ENV fiddling --- tests/acceptance/test_write_during_migration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/test_write_during_migration.rb b/tests/acceptance/test_write_during_migration.rb index 83cc6d1..96ba97d 100755 --- a/tests/acceptance/test_write_during_migration.rb +++ b/tests/acceptance/test_write_during_migration.rb @@ -204,14 +204,16 @@ class TestWriteDuringMigration < Test::Unit::TestCase end def test_mirroring_can_be_restarted + @size = 100 * 1024 * 1024 # 100MB Dir.mktmpdir do |tmpdir| Dir.chdir(tmpdir) do make_files - ENV['DEBUG'] = '1' launch_servers - ENV.delete 'DEBUG' + # This is a bit racy. It needs to be slow enough that the migration + # isn't finished before the stop runs, and slow enough so that we can + # stop/start a few times. 3.times do start_mirror sleep 0.1