adohe-zz / etcd4j

A more powerful and stable etcd java client.
MIT License
36 stars 18 forks source link

fix index overflow #15

Closed billowqiu closed 5 years ago

billowqiu commented 5 years ago

in etcd doc If we miss all the 1000 events, we need to recover the current state of the watching key space through a get and then start to watch from the X-Etcd-Index + 1.

For example, we set /other="bar" for 2000 times and try to wait from index 8.

curl 'http://127.0.0.1:2379/v2/keys/foo?wait=true&waitIndex=8'

We get the index is outdated response, since we miss the 1000 events kept in etcd.

{"errorCode":401,"message":"The event in requested index is outdated and cleared","cause":"the requested history has been cleared [1008/8]","index":2007}

The index is a long type, when index is bigger than 2,147,483,647(2^31 - 1) gson will throw an NumberFormatException.

adohe-zz commented 5 years ago

@billowqiu thanks for this PR~ just wondering are u still using this library? This client is just for etcd v2.

billowqiu commented 5 years ago

We're just using v2 right now.