Skip to content

ZOOKEEPER-4471: Match removing WatcherType to standard, persistent modes#1998

Merged
tisonkun merged 2 commits into
apache:masterfrom
kezhuw:ZOOKEEPER-4471-remove-watches
Jun 13, 2023
Merged

ZOOKEEPER-4471: Match removing WatcherType to standard, persistent modes#1998
tisonkun merged 2 commits into
apache:masterfrom
kezhuw:ZOOKEEPER-4471-remove-watches

Conversation

@kezhuw

@kezhuw kezhuw commented May 6, 2023

Copy link
Copy Markdown
Member

Before ZOOKEEPER-1416, WatcherType.Children was used to remove watchers attached through ZooKeeper.getChildren. WatcherType.Data was used to remove watchers attached through ZooKeeper.getData and ZooKeeper.exists.

ZOOKEEPER-1416 adds AddWatchMode.PERSISTENT. This watcher could be completed remove using WatcherType.Any. But when removing through WatcherType.Data or WatcherType.Children, part of AddWatchMode.PERSISTENT will be left behind. And we get persistent children or data watchers.

We are never claiming to support these type of watchers. So fix it.

In rare chance, we are going to support persistent data or children watchers in future, I think we probably don't want to do such "magic" thing in ZooKeeper. So fix it.

This is a step towards ZOOKEEPER-4472 which proposed to support WatcherType.Persistent and WatcherType.PersistentRecursive to remove persistent watchers.

@kezhuw
kezhuw force-pushed the ZOOKEEPER-4471-remove-watches branch 3 times, most recently from 9b3a2f3 to 287c86e Compare May 6, 2023 19:01
@kezhuw

kezhuw commented May 8, 2023

Copy link
Copy Markdown
Member Author

We are approaching ZOOKEEPER-4472.

Combine them all, we will have orthogonal watcher modes for clients. Watching or un-watching a path in one mode will not break other watching modes on same path.

cc @eolivelli @tisonkun @Randgalt @symat @maoling @cnauroth

Before ZOOKEEPER-1416, `WatcherType.Children` was used to remove
watchers attached through `ZooKeeper.getChildren`. `WatcherType.Data`
was used to remove watchers attached through `ZooKeeper.getData` and
`ZooKeeper.exists`.

ZOOKEEPER-1416 adds `AddWatchMode.PERSISTENT`. This watcher could be
completed remove using `WatcherType.Any`. But when removing through
`WatcherType.Data` or `WatcherType.Children`, part of
`AddWatchMode.PERSISTENT` will be left behind. And we get persistent
children or data watchers.

We are never claiming to support these type of watchers. So fix it.

In rare chance, we are going to support persistent data or children
watchers in future, I think we probably don't want to do such "magic"
thing in ZooKeeper. So fix it.

This is a step towards ZOOKEEPER-4472 which proposed to support
`WatcherType.Persistent` and `WatcherType.PersistentRecursive` to remove
persistent watchers.

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

I found it somewhat hard to follow in self-review. Add given-when-then
comments from my best hope for reviewing and maintenance.
@kezhuw

kezhuw commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

Failure test case run reported at ZOOKEEPER-4512.

@kezhuw kezhuw closed this Jun 13, 2023
@kezhuw kezhuw reopened this Jun 13, 2023

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@kezhuw

kezhuw commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

Great! Thank you for reviewing! @tisonkun @eolivelli

The cpp tests hang, I will reopen this pr for another ci run.

@kezhuw kezhuw closed this Jun 13, 2023
@kezhuw kezhuw reopened this Jun 13, 2023
@kezhuw

kezhuw commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

This is the link to previous ci run, the cpp tests hang for almost 5 hours.

https://github.com/apache/zookeeper/actions/runs/5251856628/jobs/9487231863

@kezhuw

kezhuw commented Jun 13, 2023

Copy link
Copy Markdown
Member Author

All checks are green. Can we merge this and move forward to #2006 ? @eolivelli @tisonkun

@tisonkun

Copy link
Copy Markdown
Member

I think it's good to go. Merging...

Thanks for your contribution @kezhuw!

@tisonkun
tisonkun merged commit b8d458f into apache:master Jun 13, 2023
anurag-harness pushed a commit to anurag-harness/zookeeper that referenced this pull request Aug 31, 2023
…des (apache#1998)

* ZOOKEEPER-4471: Match removing WatcherType to standard, persistent modes

Before ZOOKEEPER-1416, `WatcherType.Children` was used to remove
watchers attached through `ZooKeeper.getChildren`. `WatcherType.Data`
was used to remove watchers attached through `ZooKeeper.getData` and
`ZooKeeper.exists`.

ZOOKEEPER-1416 adds `AddWatchMode.PERSISTENT`. This watcher could be
completed remove using `WatcherType.Any`. But when removing through
`WatcherType.Data` or `WatcherType.Children`, part of
`AddWatchMode.PERSISTENT` will be left behind. And we get persistent
children or data watchers.

We are never claiming to support these type of watchers. So fix it.

In rare chance, we are going to support persistent data or children
watchers in future, I think we probably don't want to do such "magic"
thing in ZooKeeper. So fix it.

This is a step towards ZOOKEEPER-4472 which proposed to support
`WatcherType.Persistent` and `WatcherType.PersistentRecursive` to remove
persistent watchers.

* Refactor newly added tests in WatchManagerTest

I found it somewhat hard to follow in self-review. Add given-when-then
comments from my best hope for reviewing and maintenance.
anurag-harness added a commit to anurag-harness/zookeeper that referenced this pull request Aug 31, 2023
…des (apache#1998) (#51)

* ZOOKEEPER-4471: Match removing WatcherType to standard, persistent modes

Before ZOOKEEPER-1416, `WatcherType.Children` was used to remove
watchers attached through `ZooKeeper.getChildren`. `WatcherType.Data`
was used to remove watchers attached through `ZooKeeper.getData` and
`ZooKeeper.exists`.

ZOOKEEPER-1416 adds `AddWatchMode.PERSISTENT`. This watcher could be
completed remove using `WatcherType.Any`. But when removing through
`WatcherType.Data` or `WatcherType.Children`, part of
`AddWatchMode.PERSISTENT` will be left behind. And we get persistent
children or data watchers.

We are never claiming to support these type of watchers. So fix it.

In rare chance, we are going to support persistent data or children
watchers in future, I think we probably don't want to do such "magic"
thing in ZooKeeper. So fix it.

This is a step towards ZOOKEEPER-4472 which proposed to support
`WatcherType.Persistent` and `WatcherType.PersistentRecursive` to remove
persistent watchers.

* Refactor newly added tests in WatchManagerTest

I found it somewhat hard to follow in self-review. Add given-when-then
comments from my best hope for reviewing and maintenance.

Co-authored-by: Kezhu Wang <kezhuw@gmail.com>
@kezhuw
kezhuw deleted the ZOOKEEPER-4471-remove-watches branch September 24, 2023 15:08
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