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

Andrew Kyle Purtell updated ZOOKEEPER-5122:
-------------------------------------------
    Description: 
The C client allocated xids from one process global counter seeded with 
time(0). That left only about 350 million xids before the counter wrapped to 
{{INT32_MIN}}. The server ignores requests with {{xid <= 0}} when it counts 
outstanding requests ({{ServerCnxn.incrOutstandingAndCheckThrottle}} and 
{{decrOutstandingAndCheckThrottle}}). So, from the wrap on, requests from a C 
client bypass request throttling, and the server stops updating {{lastCxid}} 
for the connection. After roughly another 2 billion requests, the counter 
reaches the reserved xids of watch events and control frames (-8 SetWatches, -4 
auth, -2 ping, -1 watch event). Replies could then go to internal handlers 
instead of application completions and desynchronize the request queue.

In the single threaded library, the increment past {{INT32_MAX}} is also 
undefined behavior.

  was:The C client allocates xids using a global signed integer initialized at 
process startup with {{{}time(0){}}}. This is unnecessary and today leaves only 
about 350 million xids before the wrap, so busy clients reach it in production. 
It then wraps into negative values, causing collisions with reserved negative 
IDs used by internal protocol frames. The client misroutes incoming server 
replies to internal protocol handlers rather than the application's completion 
callbacks. Depending on which reserved ID is hit, this desynchronizes the 
in-flight request queue, triggers false authentication failures 
({{{}ZOO_AUTH_FAILED_STATE{}}}), or abruptly drops the connection with a 
{{ZRUNTIMEINCONSISTENCY}} error.


> (C client) xid counter is unnecessarily likely to wrap
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-5122
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5122
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: c client
>            Reporter: Andrew Kyle Purtell
>            Assignee: Andrew Kyle Purtell
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The C client allocated xids from one process global counter seeded with 
> time(0). That left only about 350 million xids before the counter wrapped to 
> {{INT32_MIN}}. The server ignores requests with {{xid <= 0}} when it counts 
> outstanding requests ({{ServerCnxn.incrOutstandingAndCheckThrottle}} and 
> {{decrOutstandingAndCheckThrottle}}). So, from the wrap on, requests from a C 
> client bypass request throttling, and the server stops updating {{lastCxid}} 
> for the connection. After roughly another 2 billion requests, the counter 
> reaches the reserved xids of watch events and control frames (-8 SetWatches, 
> -4 auth, -2 ping, -1 watch event). Replies could then go to internal handlers 
> instead of application completions and desynchronize the request queue.
> In the single threaded library, the increment past {{INT32_MAX}} is also 
> undefined behavior.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to