etcd-io / etcd-io/jetcd

When an error occurs, watch will only reconnect once.

Open
#1,227 4 comments 0 reactions 0 assignees View on GitHub
waiting-for-feedback
Dominant language
Java
Stars
1.2k
Forks
312
Avg merge
5d 4h
Merged PRs (30d)
2

Description

**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**
1. Use watchClient to listen for certain key-value pairs.
```java
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
}
});
}
```

2. Disconnecting the network connection, lasting for about 1 minute.

3. 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.
```java
private void reschedule() {
Futures.addCallback(executor.schedule(this::resume, 500, TimeUnit.MILLISECONDS), new FutureCallback() {
@Override
public void onFailure(Throwable throwable) {
LOG.warn("scheduled resume failed", throwable);
}

@Override
public void onSuccess(Object result) {
}
}, executor);
}
```

Contributor guide

Open the contributing guide

Research direction

Read WatchImpl.java, starting with reschedule() and the resume path used after an onError event. Reproduce the watchClient example while repeatedly disconnecting the network, then verify that failed reconnection attempts continue retrying instead of stopping after one attempt.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.