I could see how the asynchronous variant has value, but it'd require a
callback that sets a flag, like with an AtomicBoolean.  Basically, submit
it, then do the read, *then* check that the boolean is true.  If it isn't,
consider the read stale and try again (or throw).  This way we don't wait
on the sync call to finish for the common code-path.

On Sun, Mar 30, 2025 at 11:27 PM David Smiley <[email protected]> wrote:

> Thanks for explaining things.  I'll just use "/" then :-)
>
> If sync() fails, the code I have in mind would simply fail as well (since
> the subsequent read wouldn't even be reached), which is not a
> misleading/false result.  Maybe you are saying sync would asynchronously
> fail... okay but then wouldn't the subsequent read fail?  If it wouldn't...
> well that's a shame; what a confusing API!  My goal (of course) is to make
> a specific read operation a quorum operation.  It's too bad there isn't a
> *clear* way to do that correctly.
>
> On Sat, Mar 29, 2025 at 11:12 PM Kezhu Wang <[email protected]> wrote:
>
>> Hi,
>>
>> Currently, "path" has no meaning in "ZooKeeper.sync()".
>> ZOOKEEPER-3414[1] proposes to throw "NoNodeException" when "path" does
>> not exist. But it is not delivered. I used to use "/".
>>
>> Regarding the "callback", it is crucial in asynchronous, as
>> "ZooKeeper.sync" could fail due to connection issues while following
>> reads could succeed after reconnection. ZOOKEEPER-4747[2] introduces a
>> synchronous version to ease the callback handle.
>>
>> [1]: https://issues.apache.org/jira/browse/ZOOKEEPER-3414
>> [2]: https://issues.apache.org/jira/browse/ZOOKEEPER-4747
>>
>> Best,
>> Kezhu Wang
>>
>> On Fri, Mar 28, 2025 at 9:38 PM David Smiley <[email protected]> wrote:
>> >
>> > The javadocs on ZooKeeper.sync() are extremely sparse; nobody would
>> > understand this by only looking at it.  I've looked at the programmer's
>> > guide, which actually explains its use.  The callback appears pointless?
>> > Does the semantics of "sync" apply only to reading the path and its
>> > children list, or does it apply recursively to descendants beneath this
>> > path?
>> >
>> > ~ David Smiley
>> > Apache Lucene/Solr Search Developer
>> > http://www.linkedin.com/in/davidwsmiley
>>
>

Reply via email to