Skip to content

Conversation

@kezhuw
Copy link
Member

@kezhuw kezhuw commented Jun 10, 2023

ZOOKEEPER-4466 supports different watch modes one same path, but there are no corresponding WatcherTypes for persistent watches. Client has to resort to WatcherType.Any to remove them. This could accidently interrupt other watches.

This PR adds WatcherType.Persistent and WatcherType.PersistentRecursive to remove persistent watches individually.

Besides above, this pr bases on #1998.

@kezhuw kezhuw changed the title Zookeeper 4472 remove persistent watchers individually ZOOKEEPER-4472: Remove persistent watches individually Jun 10, 2023
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

@kezhuw kezhuw closed this Jun 10, 2023
@kezhuw kezhuw reopened this Jun 10, 2023
@kezhuw kezhuw force-pushed the ZOOKEEPER-4472-remove-persistent-watchers-individually branch from cd11e2b to cecc2ea Compare June 13, 2023 11:02
@kezhuw
Copy link
Member Author

kezhuw commented Jun 13, 2023

ReadOnlyModeTest.testConnectionEvents failed. There are candidates to fix this #1667 and #1896.

ZOOKEEPER-4466 supports different watch modes one same path, but there
are no corresponding `WatcherType`s for persistent watches. Client has
to resort to `WatcherType.Any` to remove them. This could accidently
interrupt other watches.

This PR adds `WatcherType.Persistent` and `WatcherType.PersistentRecursive`
to remove persistent watches individually.
@kezhuw kezhuw force-pushed the ZOOKEEPER-4472-remove-persistent-watchers-individually branch from 421d0ab to 83d3ea9 Compare June 13, 2023 13:23
@tisonkun tisonkun self-requested a review June 13, 2023 13:24
synchronized (childWatches) {
containsWatcher = contains(path, watcher, childWatches);
}

Copy link
Member

Choose a reason for hiding this comment

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

I agree on this direction that it delivers more reasonable behaviors. But it can somehow still a user-facing manner changes. Maybe we need a release note to describe it.

I'll check the final logic tomorrow and give a review result :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Here are my findings:

  • containsWatcher is package private and used solely by ZKWatchManager::removeWatcher.
  • removeWatcher enforces more stringent NoWatcherException check than containsWatcher.

So, we are in lucking path that partially removing WatcherType::Data from AddWatchMode::Persistent is an error even it is permitted by server side(a.k.a rc is 0) and containsWatcher.

I pushed a test commit for this. I also pushed tests in kezhuw@8c35fce before ZOOKEEPER-4466. All these tests result in NOWATCHER when removing WatcherType::Data from AddWatchMode::Persistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have add "Release Note" to ZOOKEEPER-4466, ZOOKEEPER-4471 and ZOOKEEPER-4472.

Is that sufficient for us ? @eolivelli @tisonkun @anmolnar

@tisonkun tisonkun self-requested a review June 15, 2023 04:56
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM now.

@tisonkun
Copy link
Member

Merging...

@tisonkun tisonkun merged commit e8b2fbe into apache:master Jun 15, 2023
@eolivelli
Copy link
Contributor

For the release notes the release manager should write it in the news page.
Tagging @anmolnar who is the RM for 3.9.0

anurag-harness pushed a commit to anurag-harness/zookeeper that referenced this pull request Aug 31, 2023
* ZOOKEEPER-4472: Remove persistent watches individually

ZOOKEEPER-4466 supports different watch modes one same path, but there
are no corresponding `WatcherType`s for persistent watches. Client has
to resort to `WatcherType.Any` to remove them. This could accidently
interrupt other watches.

This PR adds `WatcherType.Persistent` and `WatcherType.PersistentRecursive`
to remove persistent watches individually.

* Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible

* fixup! Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible
anurag-harness added a commit to anurag-harness/zookeeper that referenced this pull request Aug 31, 2023
…53)

* ZOOKEEPER-4472: Remove persistent watches individually

ZOOKEEPER-4466 supports different watch modes one same path, but there
are no corresponding `WatcherType`s for persistent watches. Client has
to resort to `WatcherType.Any` to remove them. This could accidently
interrupt other watches.

This PR adds `WatcherType.Persistent` and `WatcherType.PersistentRecursive`
to remove persistent watches individually.

* Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible

* fixup! Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible

Co-authored-by: Kezhu Wang <[email protected]>
rahulrane50 pushed a commit to rahulrane50/zookeeper that referenced this pull request Sep 15, 2023
* ZOOKEEPER-4472: Remove persistent watches individually

ZOOKEEPER-4466 supports different watch modes one same path, but there
are no corresponding `WatcherType`s for persistent watches. Client has
to resort to `WatcherType.Any` to remove them. This could accidently
interrupt other watches.

This PR adds `WatcherType.Persistent` and `WatcherType.PersistentRecursive`
to remove persistent watches individually.

* Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible

* fixup! Assert removing WatcherType::Data from AddWatchMode::Persistent is impossible
@kezhuw kezhuw deleted the ZOOKEEPER-4472-remove-persistent-watchers-individually branch September 24, 2023 15:07
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.

3 participants