Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 90D2D18AAA for ; Mon, 19 Oct 2015 08:08:44 +0000 (UTC) Received: (qmail 99840 invoked by uid 500); 19 Oct 2015 08:08:44 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 99793 invoked by uid 500); 19 Oct 2015 08:08:44 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 99784 invoked by uid 99); 19 Oct 2015 08:08:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Oct 2015 08:08:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 58485DFD7A; Mon, 19 Oct 2015 08:08:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kxepal@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: couch commit: updated refs/heads/master to acfd7cb Date: Mon, 19 Oct 2015 08:08:44 +0000 (UTC) Repository: couchdb-couch Updated Branches: refs/heads/master 79b5243ae -> acfd7cb0c Fix race condition in workqueue test. Failure seen at least once in about 150 test runs: ``` Queue with max size of 160 bytes and 3 max items couch_work_queue_tests:143: should_have_no_items_for_new_queue...ok **error:{assertEqual_failed,[{module,couch_work_queue_tests}, {line,210}, {expression,"couch_work_queue : item_count ( Q )"}, {expected,3}, {value,2}]} ``` From ``` should_block_producer_on_full_queue_count({Q, Producer, _}) -> ... produce(Q, Producer, 20, false), ?assertEqual(3, couch_work_queue:item_count(Q)), ``` Race condition is: telling Producer to produce, not waiting for queue size to be updated, and then immediately checking item_count. To make failure occur reliably insert timer:sleep(10) in producer_loop after ```Parent ! {item, Ref, Item}``` line. The fix is to wait for queue size to be updated by using the wait mode for produce function. COUCHDB-2848 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/acfd7cb0 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/acfd7cb0 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/acfd7cb0 Branch: refs/heads/master Commit: acfd7cb0c709345f396cbcb696b6305091dfac12 Parents: 79b5243 Author: Nick Vatamaniuc Authored: Mon Oct 19 02:05:46 2015 -0400 Committer: Nick Vatamaniuc Committed: Mon Oct 19 02:05:46 2015 -0400 ---------------------------------------------------------------------- test/couch_work_queue_tests.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/acfd7cb0/test/couch_work_queue_tests.erl ---------------------------------------------------------------------- diff --git a/test/couch_work_queue_tests.erl b/test/couch_work_queue_tests.erl index 96be7da..4f81013 100644 --- a/test/couch_work_queue_tests.erl +++ b/test/couch_work_queue_tests.erl @@ -206,7 +206,7 @@ should_block_producer_on_full_queue_count({Q, Producer, _}) -> ?assertEqual(2, couch_work_queue:item_count(Q)), ok = ping(Producer), - produce(Q, Producer, 20, false), + produce(Q, Producer, 20, true), ?assertEqual(3, couch_work_queue:item_count(Q)), Pong = ping(Producer),