Skip to content

Commit

Permalink
#178 - Working on ZkController close and a bit extra on overseer pop …
Browse files Browse the repository at this point in the history
…up prevention.
  • Loading branch information
markrmiller committed Jul 15, 2020
1 parent e537b80 commit 8878962
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void runLeaderProcess(ElectionContext context, boolean weAreReplacement, int pau
super.runLeaderProcess(context, weAreReplacement, pauseBeforeStartMs);

synchronized (this) {
if (!this.isClosed && !overseer.getZkController().getCoreContainer().isShutDown()) {
if (!this.isClosed && !overseer.getZkController().getCoreContainer().isShutDown() && (overseer.getUpdaterThread() == null || !overseer.getUpdaterThread().isAlive())) {
overseer.start(id, context);
}
}
Expand Down
40 changes: 21 additions & 19 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public class ZkController implements Closeable {

public final static String COLLECTION_PARAM_PREFIX = "collection.";
public final static String CONFIGNAME_PROP = "configName";
private String closeStack;

static class ContextKey {

Expand Down Expand Up @@ -596,28 +595,31 @@ public void disconnect() {
* Closes the underlying ZooKeeper client.
*/
public void close() {
if (this.isClosed) {
throw new AssertionError(closeStack);
}
log.info("Closing ZkController");
assert !this.isClosed;

this.isClosed = true;
StringBuilderWriter sw = new StringBuilderWriter(1000);
PrintWriter pw = new PrintWriter(sw);
new ObjectReleaseTracker.ObjectTrackerException(this.getClass().getName()).printStackTrace(pw);
this.closeStack = sw.toString();

try (ParWork closer = new ParWork(this, true)) {
// nocommit
closer.add("Cleanup&Terms", collectionToTerms.values());
closer.add("ZkController Internals",
electionContexts.values(), cloudManager, sysPropsCacher, cloudSolrClient, zkStateReader, closeZkClient ? zkClient : null);
ElectionContext context = null;
if (overseerElector != null) {
context = overseerElector.getContext();
}
closer.add("ZkController Internals", context, overseerContexts.values() , overseer);
} finally {
assert ObjectReleaseTracker.release(this);
closer.collect(electionContexts.values());
closer.collect(cloudManager);
closer.collect(collectionToTerms.values());
closer.collect(sysPropsCacher);
closer.collect(cloudSolrClient);

closer.collect(zkStateReader);
if (closeZkClient) {
closer.collect(zkClient);
}
if (overseerElector != null && overseerElector.getContext() != null ) {
closer.collect(overseerElector.getContext());
}

closer.collect(overseerContexts.values());
closer.collect(overseer);
closer.addCollect("closeZkController");
}
assert ObjectReleaseTracker.release(this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion solr/solrj/src/java/org/apache/solr/common/ParWork.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ private void handleObject(String label, AtomicReference<Throwable> exception, fi

if (!handled) {
String msg = label + " -> I do not know how to close: " + object.getClass().getName();
log.error(RAN_INTO_AN_ERROR_WHILE_DOING_WORK, msg);
log.error(msg);
IllegalArgumentException illegal = new IllegalArgumentException(msg);
exception.set(illegal);
}
Expand Down

0 comments on commit 8878962

Please sign in to comment.