[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-1485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15314712#comment-15314712
 ] 

Martin Kuchta commented on ZOOKEEPER-1485:
------------------------------------------

That makes sense. I probably should have brushed up on my knowledge of the Java 
client and ZooKeeper states in general before asking, but thanks for the 
clarification.

With that information, I think having the server expire a client's session when 
it receives a negative XID would fix the issue in the Java client. The issue 
would remain in the C client because XID initialization is still tied to the 
start of the process and not the ZooKeeper handle initialization. I can see two 
potential fixes for the overall problem.

a) Expire the session upon receiving a negative XID. Modify the C client to 
make the XID a member of the zhandle struct to more closely mirror the Java 
client. Initialize the new XID struct member in zookeeper_init_internal.

b) Modify both clients to wrap the XID around as described above.

These aren't mutually exclusive either. Option (a) would ensure XID uniqueness 
for all requests made by a single connection (not currently done because XIDs 
will be reused when they wrap all the way around to the starting value). Option 
(b) is a simpler (and probably lower risk) fix, being a small value check in 
the client code only.

> client xid overflow is not handled
> ----------------------------------
>
>                 Key: ZOOKEEPER-1485
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1485
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: c client, java client
>    Affects Versions: 3.4.3, 3.3.5
>            Reporter: Michi Mutsuzaki
>            Assignee: Bruce Gao
>
> Both Java and C clients use signed 32-bit int as XIDs. XIDs are assumed to be 
> non-negative, and zookeeper uses some negative values as special XIDs (e.g. 
> -2 for ping, -4 for auth). However, neither Java nor C client ensures the 
> XIDs it generates are non-negative, and the server doesn't reject negative 
> XIDs.
> Pat had some suggestions on how to fix this:
> - (bin-compat) Expire the session when the client sends a negative XID.
> - (bin-incompat) In addition to expiring the session, use 64-bit int for XID 
> so that overflow will practically never happen.
> --Michi



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to