You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Austin Shoemaker (JIRA)" <ji...@apache.org> on 2010/10/07 09:55:31 UTC

[jira] Created: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

C client invokes watcher callbacks multiple times
-------------------------------------------------

                 Key: ZOOKEEPER-890
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
             Project: Zookeeper
          Issue Type: Bug
          Components: c client
    Affects Versions: 3.3.1
         Environment: Mac OS X 10.6.5
            Reporter: Austin Shoemaker
            Priority: Critical
         Attachments: watcher_twice.c

The collect_session_watchers function in zk_hashtable.c gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing the watchers from the table.

Please see attached repro case and patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Jared Cantwell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919087#action_12919087 ] 

Jared Cantwell commented on ZOOKEEPER-890:
------------------------------------------

I don't believe the C-client makes the guarantee that "watcher callbacks are called exactly once."  Callbacks are called for different reasons, including:

- connection lost event
- connection reestablished event
- session lost event
- data changed event

Only the last two events make the guarantee about being called exactly once, but the first two connection events can be called numerous times until either one of the last two events happens.  I may be missing some events, but that's the general idea.  Bottom line is the callback can receive events of type ZOO_SESSION_EVENT multiple times.  I believe this was by design.

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.
> collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.
> Test code is attached that reproduces the bug, along with a proposed patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Shoemaker updated ZOOKEEPER-890:
---------------------------------------

    Description: 
Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.

collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.

Test code is attached that reproduces the bug, along with a proposed patch.

  was:
The collect_session_watchers function in zk_hashtable.c gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing the watchers from the table.

Please see attached repro case and patch.


> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.
> collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.
> Test code is attached that reproduces the bug, along with a proposed patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919094#action_12919094 ] 

Austin Shoemaker commented on ZOOKEEPER-890:
--------------------------------------------

That sounds like a good design. Perhaps it could be clarified in the documentation?
http://hadoop.apache.org/zookeeper/docs/r3.3.1/zookeeperProgrammers.html#ch_zkWatches

If this is correct behavior then the Python client needs to be fixed to not delete the watcher on session events. Will file a separate bug on that.

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.
> collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.
> Test code is attached that reproduces the bug, along with a proposed patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Shoemaker updated ZOOKEEPER-890:
---------------------------------------

    Attachment: ZOOKEEPER-890.patch

Patch that clears active watcher sets when broadcasting a session event to all watchers.

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> The collect_session_watchers function in zk_hashtable.c gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing the watchers from the table.
> Please see attached repro case and patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920619#action_12920619 ] 

Patrick Hunt commented on ZOOKEEPER-890:
----------------------------------------

Should this issue be closed then? (also sounds like 2 other issues should be opened which were detailed in the comments - docs and python)

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.
> collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.
> Test code is attached that reproduces the bug, along with a proposed patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Shoemaker resolved ZOOKEEPER-890.
----------------------------------------

    Resolution: Not A Problem

Closing, C client works as intended. Submitted a patch in ZOOKEEPER-888 to handle this properly in zkpython.

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c, ZOOKEEPER-890.patch
>
>
> Code using the C client assumes that watcher callbacks are called exactly once. If the watcher is called more than once, the process will likely overwrite freed memory and/or crash.
> collect_session_watchers (zk_hashtable.c) gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing them. This results in watchers being invoked more than once.
> Test code is attached that reproduces the bug, along with a proposed patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-890) C client invokes watcher callbacks multiple times

Posted by "Austin Shoemaker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Shoemaker updated ZOOKEEPER-890:
---------------------------------------

    Attachment: watcher_twice.c

> C client invokes watcher callbacks multiple times
> -------------------------------------------------
>
>                 Key: ZOOKEEPER-890
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-890
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.3.1
>         Environment: Mac OS X 10.6.5
>            Reporter: Austin Shoemaker
>            Priority: Critical
>         Attachments: watcher_twice.c
>
>
> The collect_session_watchers function in zk_hashtable.c gathers watchers from active_node_watchers, active_exist_watchers, and active_child_watchers without removing the watchers from the table.
> Please see attached repro case and patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.