[
https://issues.apache.org/jira/browse/CURATOR-468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16711777#comment-16711777
]
ASF GitHub Bot commented on CURATOR-468:
----------------------------------------
GitHub user Randgalt opened a pull request:
https://github.com/apache/curator/pull/285
[CURATOR-468] LeaderSelector interruption causing spurious log messages,
etc.
Adds a test to what #279 had along with a slightly more complete fix. The
finally clause of doWork() releases the mutex. In an interrupted situation this
would always fail causing the failed delete manager to handle the work
resulting in slightly slower deletions and spurious log messaged. This fixes
this by clearing the thread interrupted state prior to releasing the mutex and
then resetting afterwards if needed.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/curator CURATOR-468
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/curator/pull/285.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #285
----
commit 97e76919ae0056985aacc786d6c440fb779a6877
Author: randgalt <randgalt@...>
Date: 2018-12-06T17:40:43Z
CURATOR-468
Adds a test to what #279 had along with a slightly more complete fix. The
finally clause of doWork() releases the mutex. In an interrupted situation this
would always fail causing the failed delete manager to handle the work
resulting in slightly slower deletions and spurious log messaged. This fixes
this by clearing the thread interrupted state prior to releasing the mutex and
then resetting afterwards if needed.
commit ddfcbc1e37fa9e8a9018f2c0d85b7f125efe173c
Author: randgalt <randgalt@...>
Date: 2018-12-06T17:43:16Z
Add a comment explaining
----
> Closing an active leader selector always logs spurious error
> ------------------------------------------------------------
>
> Key: CURATOR-468
> URL: https://issues.apache.org/jira/browse/CURATOR-468
> Project: Apache Curator
> Issue Type: Improvement
> Reporter: Keith Turner
> Assignee: Jordan Zimmerman
> Priority: Major
>
> Closing a a leader selector seems to always log spurious error messages.
> This only happens when it has assumed leadership because of CURATOR-337. I
> think this spurious error logging highlights a conceptual problem with the
> code. The primary reason that [LeaderSelector.java line
> 449|https://github.com/apache/curator/blob/ee5d65463b73abb2a2b732fb02729239b183519d/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java#L449]
> is executed is because the thread was interrupted. Since the interrupt is
> set for the thread the call to release the mutex will never work, so its a
> bit of a catch-22.
> Below is an example of the exception I am seeing.
> {noformat}
> 2018-05-31 20:23:51,068 [leader.LeaderSelector] ERROR: The leader threw an
> exception
> java.lang.InterruptedException
> at java.lang.Object.wait(Native Method)
> at java.lang.Object.wait(Object.java:502)
> at org.apache.zookeeper.ClientCnxn.submitRequest(ClientCnxn.java:1406)
> at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:871)
> at
> org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(DeleteBuilderImpl.java:250)
> at
> org.apache.curator.framework.imps.DeleteBuilderImpl$5.call(DeleteBuilderImpl.java:244)
> at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:109)
> at
> org.apache.curator.framework.imps.DeleteBuilderImpl.pathInForeground(DeleteBuilderImpl.java:241)
> at
> org.apache.curator.framework.imps.DeleteBuilderImpl.forPath(DeleteBuilderImpl.java:225)
> at
> org.apache.curator.framework.imps.DeleteBuilderImpl.forPath(DeleteBuilderImpl.java:35)
> at
> org.apache.curator.framework.recipes.locks.LockInternals.deleteOurPath(LockInternals.java:339)
> at
> org.apache.curator.framework.recipes.locks.LockInternals.releaseLock(LockInternals.java:123)
> at
> org.apache.curator.framework.recipes.locks.InterProcessMutex.release(InterProcessMutex.java:154)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.doWork(LeaderSelector.java:449)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.doWorkLoop(LeaderSelector.java:466)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.access$100(LeaderSelector.java:65)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderSelector.java:246)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderSelector.java:240)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> {noformat}
> Below is an example of an exception I see when closing a leader selector and
> then closing the curator framework.
> {noformat}
> 2018-05-31 20:23:49,905 [leader.LeaderSelector] ERROR: The leader threw an
> exception
> java.lang.IllegalStateException: instance must be started before calling this
> method
> at
> org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:176)
> at
> org.apache.curator.framework.imps.CuratorFrameworkImpl.delete(CuratorFrameworkImpl.java:359)
> at
> org.apache.curator.framework.recipes.locks.LockInternals.deleteOurPath(LockInternals.java:339)
> at
> org.apache.curator.framework.recipes.locks.LockInternals.releaseLock(LockInternals.java:123)
> at
> org.apache.curator.framework.recipes.locks.InterProcessMutex.release(InterProcessMutex.java:154)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.doWork(LeaderSelector.java:449)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.doWorkLoop(LeaderSelector.java:466)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector.access$100(LeaderSelector.java:65)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderSelector.java:246)
> at
> org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderSelector.java:240)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)