Skip to content

CURATOR-727: Allow watches to be executed asynchronously #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

HoustonPutman
Copy link
Contributor

https://issues.apache.org/jira/browse/CURATOR-727

This gives users the ability to run all watches asynchronously, via a provided executorService.

Copy link

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

An alternative implementation approach to sp

}
};
}
if (watchRunnable != null) {
Copy link

Choose a reason for hiding this comment

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

Perhaps more elegant to add an "else" that returns. Therefore, watchRunnable could be final non-null; no condition to act on it's null-ness.

@@ -445,6 +447,18 @@ public void close() {
unhandledErrorListeners.clear();
connectionStateManager.close();
client.close();

if (asyncWatchService != null) {
Copy link

Choose a reason for hiding this comment

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

If one of those long-running processes interacts with curator, I could see it failing. It'd be better to have close() relatively early call shutdown(), after publishing the close event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after publishing the close event.

That would happen either after connectionStateManager.close() or client.close(). So this is happening just after those are called.

But I do think we would want to skip any client connection management watches here. Those probably shouldn't be asynchronous anyways. So I'm going to look into that.

Copy link

Choose a reason for hiding this comment

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

If the "asyncExecutor" could in fact always be pre-initialized to a "direct" (same thread Executor like Guava MoreExecutors.newDirectExecutorService), then there'd be no branching check around if it's present or not. Solr uses this technique in SimpleFacets too. That said, there's little complexity here so I'm not going to recommend it.

@tisonkun
Copy link
Member

cc @eolivelli @kezhuw @Randgalt @cammckenzie

Not quite sure if such a change would break sequential assumption.

@tisonkun
Copy link
Member

tisonkun commented Mar 7, 2025

Hi @HoustonPutman!

We just released Curator 5.8.0 and it causes several code conflict. To move this PR forward, I'd suggest you rebase this patch or open a new one, referring to #1242.

And the key blocker here is to analyze and describe how running watches in a dedicated executor service won't break current sequential implementation. That is, do we depend on the sequential assumption? Or describing the current execution order to ensure that we won't break any assumption.

@HoustonPutman
Copy link
Contributor Author

Thanks for the update @tisonkun. Yeah, there is a lot to think about there, and probably will require a more intelligent feature.

This isn't a blocker for us, so we can move forward as-is with this release in Solr. But as we transfer leader election and other big features to recipes, we can come back and rethink how to approach the watch executor.

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