Skip to content

ZOOKEEPER-4749: Respect zookeeper.request.timeout also for asynchronous api - #2168

Open
kezhuw wants to merge 1 commit into
apache:masterfrom
kezhuw:ZOOKEEPER-4749-request-timeout
Open

ZOOKEEPER-4749: Respect zookeeper.request.timeout also for asynchronous api#2168
kezhuw wants to merge 1 commit into
apache:masterfrom
kezhuw:ZOOKEEPER-4749-request-timeout

Conversation

@kezhuw

@kezhuw kezhuw commented May 29, 2024

Copy link
Copy Markdown
Member

Currently, zookeeper.request.timeout is only respected in synchronous api. I think there are should be no much differences between following two.

String createdPath = zk.create("/path", data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
CompletableFuture<String> future = new CompletableFuture<>();
zk.create("/path", data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, (rc, path, ctx, name) -> {
    if (rc == 0) {
        future.complete(name);
    } else {
        future.completeExceptionally(KeeperException.create(KeeperException.Code.get(rc), path));
    }
}, null);
String createdPath = future.join();

After this pr, we are able to unify synchronous api through calls to asynchronous api as review comments pointed out if we feel there are too much identical code between synchronous and asynchronous api.

@kezhuw kezhuw left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After read ZOOKEEPER-2251. I think we were introducing a feature to solve/circumvent a not reproduced bug.

  • zookeeper.request.timeout is somewhat similar to connectTimeout.
  • The stack show that packet was not notified or finished.

I did not find matching git tag for that stack dump.

packet.wait();
}
}
if (r.getErr() == Code.REQUESTTIMEOUT.intValue()) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not guarantee Code.REQUESTTIMEOUT in returning as sendThread.cleanAndNotifyState() will reset r.err to Code.CONNECTIONLOSS. The old testing code is cheating us as it modified client side behavior.

…us api

Currently, `zookeeper.request.timeout` is only respected in synchronous
api. I think there are should be no much differences between following two.

```java
String createdPath = zk.create("/path", data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
```

```java
CompletableFuture<String> future = new CompletableFuture<>();
zk.create("/path", data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, (rc, path, ctx, name) -> {
    if (rc == 0) {
        future.complete(name);
    } else {
        future.completeExceptionally(KeeperException.create(KeeperException.Code.get(rc), path));
    }
}, null);
String createdPath = future.join();
```

After this pr, we are able to unify synchronous api through calls to
asynchronous api as [review comments][review-comments] pointed out if we
feel there are too much identical code between synchronous and asynchronous
api.

[review-comments]: apache#2068 (comment)
@showuon

showuon commented Dec 2, 2024

Copy link
Copy Markdown
Member

We recently encountered this issue, too. Do we have any update to this PR?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants