summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Avdey <eiri@eiri.ca>2017-06-23 18:01:59 +0000
committerEric Avdey <eiri@eiri.ca>2017-06-23 18:03:37 +0000
commit9ea4ad83d3f847d8ab12f4bdf7c8437a8b8d4864 (patch)
treece2b3862197030e936e0e0fb6753372358c8e74d
parent7105971725f0c6103f088a3d9bf2f8b407b300c7 (diff)
downloadcouchdb-9ea4ad83d3f847d8ab12f4bdf7c8437a8b8d4864.tar.gz
Address a race on compacting process exit
View compacting process can be just a bit slow on exit after swap_compacted call. This leads to the test failure, because compacting process holding on db monitor
-rw-r--r--src/couch/test/couchdb_compaction_daemon_tests.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/couch/test/couchdb_compaction_daemon_tests.erl b/src/couch/test/couchdb_compaction_daemon_tests.erl
index dcb1b5fe3..fdb6654b4 100644
--- a/src/couch/test/couchdb_compaction_daemon_tests.erl
+++ b/src/couch/test/couchdb_compaction_daemon_tests.erl
@@ -216,6 +216,7 @@ spawn_compaction_monitor(DbName) ->
end),
{ok, ViewPid} = couch_index_server:get_index(couch_mrview_index,
DbName, <<"_design/foo">>),
+ {ok, CompactorPid} = couch_index:get_compactor_pid(ViewPid),
TestPid ! {self(), started},
receive
{TestPid, go} -> ok
@@ -238,6 +239,16 @@ spawn_compaction_monitor(DbName) ->
DbPid,
?TIMEOUT
),
+ meck:reset(couch_mrview_compactor),
+ meck:wait(
+ 1,
+ couch_mrview_compactor,
+ compact,
+ ['_', '_', '_'],
+ ?TIMEOUT
+ ),
+ {ok, CPid} = couch_index_compactor:get_compacting_pid(CompactorPid),
+ CRef = erlang:monitor(process, CPid),
meck:wait(
1,
couch_mrview_compactor,
@@ -245,7 +256,12 @@ spawn_compaction_monitor(DbName) ->
['_', '_'],
ViewPid,
?TIMEOUT
- )
+ ),
+ receive
+ {'DOWN', CRef, process, _, _} -> ok
+ after ?TIMEOUT ->
+ erlang:error(timeout)
+ end
end),
receive
{Pid, started} -> ok;