You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/09/09 22:15:00 UTC

[jira] [Updated] (ZOOKEEPER-4372) Zookeeper lock recipe doesn't parse negative sequence numbers correctly

     [ https://issues.apache.org/jira/browse/ZOOKEEPER-4372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated ZOOKEEPER-4372:
--------------------------------------
    Labels: pull-request-available  (was: )

> Zookeeper lock recipe doesn't parse negative sequence numbers correctly
> -----------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-4372
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4372
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: recipes
>            Reporter: Colin McIntosh
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> According to the Zookeeper docs ZNode sequence numbers will rollover to -2147483648 after reaching 2147483647 (I've also confirmed this is the case in practice):
> [https://zookeeper.apache.org/doc/r3.7.0/zookeeperProgrammers.html#Sequence+Nodes+–+Unique+Naming|https://zookeeper.apache.org/doc/r3.7.0/zookeeperProgrammers.html#Sequence+Nodes+%E2%80%93+Unique+Naming]
>  
> When this rollover happens the negative symbol is incorrectly stripped off the sequence number in ZNodeName due to this code searching for the last index of "-", thus the sequence number parsed is always the absolute value:
> [https://github.com/apache/zookeeper/blob/1e74a3395a9c3c4d67093f9a073bffb5a176916c/zookeeper-recipes/zookeeper-recipes-lock/src/main/java/org/apache/zookeeper/recipes/lock/ZNodeName.java#L54]
>  
> This results in any subsequently created sequence numbers being considered the "lowest" due to the absolute value decrementing until reaching 0. It also looks like there is no test to check parsing of negative sequence numbers.
>  
> For context, this same issue arose in the unofficial Golang client recipe and there is a proposed fix there: [https://github.com/go-zookeeper/zk/pull/65]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)