You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2022/09/01 16:05:51 UTC

[couchdb] 22/31: Address race in cpse_incref_decref test

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch raft_storemodule
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit af42d364f602c4d06dddd1299157315292dd3b46
Author: Jay Doane <ja...@apache.org>
AuthorDate: Mon Jul 25 15:05:45 2022 -0700

    Address race in cpse_incref_decref test
    
    Occasionally, this test fails with the following stack trace:
    
          cpse_gather: make_test_fun (cpse_incref_decref)...*failed*
    in function cpse_test_ref_counting:'-cpse_incref_decref/1-fun-0-'/2 (src/cpse_test_ref_counting.erl, line 44)
    in call from cpse_test_ref_counting:cpse_incref_decref/1 (src/cpse_test_ref_counting.erl, line 44)
    in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
    in call from eunit_proc:run_test/1 (eunit_proc.erl, line 522)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 347)
    in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 505)
    in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 447)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 337)
    **error:{assert,[{module,cpse_test_ref_counting},
             {line,44},
             {expression,"lists : member ( Pid , Pids1 )"},
             {expected,true},
             {value,false}]}
      output:<<"">>
    
    Wrap the former assertion in a `test_util:wait` call to account for
    the apparent race between client readiness and
    `couch_db_engine:monitored_by/1`.
---
 src/couch_pse_tests/src/cpse_test_ref_counting.erl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/couch_pse_tests/src/cpse_test_ref_counting.erl b/src/couch_pse_tests/src/cpse_test_ref_counting.erl
index a0123d1ca..e56321080 100644
--- a/src/couch_pse_tests/src/cpse_test_ref_counting.erl
+++ b/src/couch_pse_tests/src/cpse_test_ref_counting.erl
@@ -40,8 +40,15 @@ cpse_incref_decref({Db, _}) ->
     {Pid, _} = Client = start_client(Db),
     wait_client(Client),
 
-    Pids1 = couch_db_engine:monitored_by(Db),
-    ?assert(lists:member(Pid, Pids1)),
+    test_util:wait(
+        fun() ->
+            MonitoredPids1 = couch_db_engine:monitored_by(Db),
+            case lists:member(Pid, MonitoredPids1) of
+                true -> ok;
+                false -> wait
+            end
+        end
+    ),
 
     close_client(Client),