You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by nickva <gi...@git.apache.org> on 2015/10/19 08:17:18 UTC

[GitHub] couchdb-couch pull request: Fix race condition in workqueue test.

GitHub user nickva opened a pull request:

    https://github.com/apache/couchdb-couch/pull/124

    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

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-couch 2848-workqueue-test-rc-fix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch/pull/124.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #124
    
----
commit acfd7cb0c709345f396cbcb696b6305091dfac12
Author: Nick Vatamaniuc <va...@gmail.com>
Date:   2015-10-19T06:05:46Z

    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

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Fix race condition in workqueue test.

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/124#issuecomment-149137886
  
    +1. Nice found!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Fix race condition in workqueue test.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-couch/pull/124


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---