jetcd icon indicating copy to clipboard operation
jetcd copied to clipboard

Watcher stop watching after few watching few changes

Open nazmul-prince opened this issue 7 months ago • 7 comments

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<Throwable> 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<WatchResponse> 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.

nazmul-prince avatar Jul 05 '24 23:07 nazmul-prince