Skip to content

Conversation

@kezhuw
Copy link
Member

@kezhuw kezhuw commented May 29, 2024

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.

Copy link
Member Author

@kezhuw kezhuw left a comment

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
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
Copy link
Member

showuon commented Dec 2, 2024

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