Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When an error occurs, watch will only reconnect once. #1227

Open
sukidesuka opened this issue Sep 14, 2023 · 3 comments
Open

When an error occurs, watch will only reconnect once. #1227

sukidesuka opened this issue Sep 14, 2023 · 3 comments

Comments

@sukidesuka
Copy link

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.
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 
                    }
                });
    }
  1. Disconnecting the network connection, lasting for about 1 minute.

  2. 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);
        }
@liangyuanpeng
Copy link
Contributor

liangyuanpeng commented Sep 15, 2023

@sukidesuka
Coud you please provide some tests code to reproduce it?

I'm try to reproduce it and got nothing.

tests step:

  1. client watch key with prefix /
  2. client put key /hello and watcher get the event
  3. sleep 2min
  4. random to restart the etcd server repeatedly, and then keep the stop time have 1min
  5. start etcd server
  6. client put key /hello
  7. watcher have get the event

@liangyuanpeng
Copy link
Contributor

Same with #1135 , but have not reproducer for it (:

@liangyuanpeng
Copy link
Contributor

ping @sukidesuka

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants