Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -933,12 +933,23 @@ public void shutdown() {
* @param fullyShutDown true if another server using the same database will not replace this one in the same process
*/
public synchronized void shutdown(boolean fullyShutDown) {
if (shutdownZKServer(fullyShutDown)) {
updateZKDatabase(fullyShutDown);
}
}

/**
* Shut down the server instance
* @param fullyShutDown true if another server using the same database will not replace this one in the same process
* @return true if the server is successfully shutdown, false if the server cannot be shutdown.
*/
protected synchronized boolean shutdownZKServer(boolean fullyShutDown) {
if (!canShutdown()) {
if (fullyShutDown && zkDb != null) {
zkDb.clear();
}
LOG.debug("ZooKeeper server is not running, so not proceeding to shutdown!");
return;
return false;
}
LOG.info("shutting down");

Expand All @@ -965,7 +976,16 @@ public synchronized void shutdown(boolean fullyShutDown) {
if (jvmPauseMonitor != null) {
jvmPauseMonitor.serviceStop();
}
requestPathMetricsCollector.shutdown();
unregisterJMX();
return true;
}

/**
* Update zk database during shutdown
* @param fullyShutDown true if another server using the same database will not replace this one in the same process
*/
protected synchronized void updateZKDatabase(boolean fullyShutDown) {
if (zkDb != null) {
if (fullyShutDown) {
zkDb.clear();
Expand All @@ -984,9 +1004,6 @@ public synchronized void shutdown(boolean fullyShutDown) {
}
}
}

requestPathMetricsCollector.shutdown();
unregisterJMX();
}

protected void unregisterJMX() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,18 @@ public synchronized void shutdown() {
}
}

@Override
public void shutdown(boolean fullyShutDown) {
if (shutdownZKServer(fullyShutDown)) {
try {
if (syncProcessor != null) {
syncProcessor.shutdown();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

7% of developers fix this issue

THREAD_SAFETY_VIOLATION: Unprotected write. Non-private method LearnerZooKeeperServer.shutdown(...) indirectly writes to field this.syncProcessor.lastFlushTime outside of synchronization.
Reporting because another access to the same memory occurs on a background thread, although this access may not.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

}
} catch (Exception e) {
LOG.warn("Ignoring unexpected exception in syncprocessor shutdown", e);
}
updateZKDatabase(fullyShutDown);
}
}

}