-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
handle zkCache failure: invalidate cache and zk-getData failure #377
Conversation
@@ -166,6 +166,23 @@ private void invalidateExists(String path) { | |||
existsCache.invalidate(path); | |||
} | |||
|
|||
public void asyncInvalidate(String path) { | |||
if (scheduledExecutor != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the executors could be null?
because in case of ZookeeperCacheLoader we depend on ForkJoinPool.
Also, it can also possible if someone pass null executor in constructor: ZooKeeperCache(ZooKeeper zkSession, OrderedSafeExecutor executor, ScheduledExecutorService scheduledExecutor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to check this in the constructor then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we have multiple tests which passes null for executor to test specific scenario. Also,
- we do handle null executor in ZkCache at multiple places
- so, if caller may pass null executor then I think it should be handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.. we can add assertion in constructor for non null executor .
3969dc7
to
38779db
Compare
@@ -95,6 +95,8 @@ | |||
private LocalZooKeeperConnectionService localZooKeeperConnectionProvider; | |||
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(20, | |||
new DefaultThreadFactory("pulsar")); | |||
private final ScheduledExecutorService cacheExecutor = Executors.newScheduledThreadPool(10, | |||
new DefaultThreadFactory("cache-callback")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to be specicif? zk-cache-callback instead of cache-callback?
@@ -166,6 +166,23 @@ private void invalidateExists(String path) { | |||
existsCache.invalidate(path); | |||
} | |||
|
|||
public void asyncInvalidate(String path) { | |||
if (scheduledExecutor != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to check this in the constructor then?
@@ -95,6 +95,8 @@ | |||
private LocalZooKeeperConnectionService localZooKeeperConnectionProvider; | |||
private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(20, | |||
new DefaultThreadFactory("pulsar")); | |||
private final ScheduledExecutorService cacheExecutor = Executors.newScheduledThreadPool(10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought - can we make the pools size configurable and put all constants in one place - for all pools cacheExecutor, scheduledExecutorScheduler and orderedExecutor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may configure number of netty-io and executor threads but I think we can create an issue and should address into different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@merlimat updated with testcases. can you please review when you get a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* handle zkCache failure: invalidate cache and zk-getData failure * introduce separate executor to serve zkcache callback * add executor to discovery service * remove testing npe * add assetion on zkCache executor parameter and update tests * update executor thread in testcase for intermittent failure
Motivation
Due to some reason if broker lose Global-Zk session then
ZooKeeperCache
should handle failure while getting data from lost zkSession.Modifications
future
from the cache so, next time when call comes then ZKCache can load fresh data from reconnected ZKSession.Result
It helps
ZooKeeperCache
to reload zk-node data if it fails earlier with zksession issue.