etcd-io / etcd-io/jetcd

Watcher stop watching after few watching few changes

Open
#1,379 7 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.4.33
- jetcd: 0.8.2
- java:21

**Describe the bug**
I'm initializing a etcd client like the following:
`this.etcdClient = Client.builder().endpoints(hosts).executorService(taskExecutor).build();`
and then initializing a watcher on a key prefix e.g. "/messages" only on startup like the following:
```
Consumer onError = e -> {
log.error("error ");
};
log.info("getting watcher client");
Watch watchClient = etcdClient.getWatchClient();
watcher = watchClient.watch(ByteSequence.from(key.getBytes(StandardCharsets.UTF_8)),
watchOption,
consumer,
onError);
log.info("started watching");
```
Here is my consumer:
```
final Consumer consumer = watchResponse -> {
boolean anyMatch = watchResponse.getEvents()
.stream()
.anyMatch(watchEvent -> Objects.equals(watchEvent.getEventType(), WatchEvent.EventType.PUT)
|| Objects.equals(watchEvent.getEventType(), WatchEvent.EventType.DELETE));

if(anyMatch) {
log.info("reload messages");
CompletableFuture.runAsync(() -> {
reloadMessages();
}, etcdLongBlockingThreadPoolTaskExecutor);
}
};
```
Now after starting the watcher, it successfully listens for few changes like 10 - 15, then its stops watching. I'm getting the following erorr in onError:
`o.etcd.jetcd.common.exception.EtcdException: gRPC message exceeds maximum size 4194304: 6619136`

then I've increased the size like the following:
` this.etcdClient = Client.builder().endpoints(hosts).maxInboundMessageSize(8 * 1024 * 1024).executorService(taskExecutor).build();`
But nothing happened, the watcher stops watching after 10 - 15 changes, Interestingly its not showing any error now.
Note: my with prefix /messages I've only 4-6 keys.
And I've checked the watcher.isClose() at that point, its returning false.

`**To Reproduce**
Just try to to set up a watcher and then watch for 10 -15 changes

**Expected behavior**
The watcher should work properly once it is initiated.

Any help will be greatly appreciated, as its a blocker for our applicatoin right now, thanks in advance.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.