When an error occurs, watch will only reconnect once.
Versions
- etcd: 3.5.9
- jetcd: 0.7.5
- java: 11
Describe the bug When my internet keeps disconnecting, the watch will only reconnect once.
To Reproduce
- Use watchClient to listen for certain key-value pairs.
client.getWatchClient().watch(ByteSequence.from(prefix.getBytes()),
WatchOption.newBuilder().isPrefix(true).withPrevKV(true).build(),
new Watch.Listener() {
@Override
public void onNext(WatchResponse watchResponse) {
// some code
}
@Override
public void onError(Throwable throwable) {
// some code
}
@Override
public void onCompleted() {
// some code
}
});
}
-
Disconnecting the network connection, lasting for about 1 minute.
-
At this point, you will find that the watch is disconnected and fails to reconnect, and it will not continue to reconnect.
Expected behavior The watch can be set to reconnect indefinitely when an onError event occurs.
Additional context I found that in WatchImpl.java, if the reconnection fails, only a warning log will be printed and it will not continue to reconnect.
private void reschedule() {
Futures.addCallback(executor.schedule(this::resume, 500, TimeUnit.MILLISECONDS), new FutureCallback<Object>() {
@Override
public void onFailure(Throwable throwable) {
LOG.warn("scheduled resume failed", throwable);
}
@Override
public void onSuccess(Object result) {
}
}, executor);
}
@sukidesuka Coud you please provide some tests code to reproduce it?
I'm try to reproduce it and got nothing.
tests step:
- client watch key with prefix
/ - client put key
/helloand watcher get the event - sleep 2min
- random to restart the etcd server repeatedly, and then keep the stop time have 1min
- start etcd server
- client put key
/hello - watcher have get the event
Same with https://github.com/etcd-io/jetcd/discussions/1135 , but have not reproducer for it (:
ping @sukidesuka