diff options
author | Nick Vatamaniuc <vatamane@gmail.com> | 2021-04-27 11:53:33 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2021-04-27 12:36:47 -0400 |
commit | 33ca7540bab8e7cab82ea19b7b0a252ab74a632d (patch) | |
tree | efa8ce3cbfe76bd9ca7e2866198d27dfe251a902 | |
parent | 4f36e466ed14df5d89f6ce17c07e287d3cb1d365 (diff) | |
download | couchdb-33ca7540bab8e7cab82ea19b7b0a252ab74a632d.tar.gz |
Fix flaky couch_jobs metadata test
Previously we deleted the ets handle cache, then bumped the FDB metadata. That
has a race condition if anything else, like fabric2_indexing or other
couch_jobs users, tried to get a jtx() handle before the metadata bump. In that
case, they would have re-inserted a handle with a stale `md_version` and the
test assertions would fail.
The fix is to first bump the md version, then delete the handles.
-rw-r--r-- | src/couch_jobs/test/couch_jobs_tests.erl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/couch_jobs/test/couch_jobs_tests.erl b/src/couch_jobs/test/couch_jobs_tests.erl index d0066724e..9f3a3721d 100644 --- a/src/couch_jobs/test/couch_jobs_tests.erl +++ b/src/couch_jobs/test/couch_jobs_tests.erl @@ -757,13 +757,15 @@ metadata_version_bump(_) -> JTx1 = couch_jobs_fdb:tx(couch_jobs_fdb:get_jtx(), fun(Tx) -> Tx end), ?assertMatch(#{md_version := not_found}, JTx1), - ets:delete_all_objects(couch_jobs_fdb), couch_jobs_fdb:bump_metadata_version(), + ets:delete_all_objects(couch_jobs_fdb), + JTx2 = couch_jobs_fdb:tx(couch_jobs_fdb:get_jtx(), fun(Tx) -> Tx end), ?assertMatch(#{md_version := Bin} when is_binary(Bin), JTx2), - ets:delete_all_objects(couch_jobs_fdb), couch_jobs_fdb:bump_metadata_version(), + ets:delete_all_objects(couch_jobs_fdb), + JTx3 = couch_jobs_fdb:tx(couch_jobs_fdb:get_jtx(), fun(Tx) -> Tx end), OldMdv = maps:get(md_version, JTx2), NewMdv = maps:get(md_version, JTx3), |