You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/16 08:49:55 UTC
[lucene-solr] branch reference_impl updated: @201 - Put a lid on
things after close.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl by this push:
new 285816a @201 - Put a lid on things after close.
285816a is described below
commit 285816afd3341a60ae8b18baa9485aa72db90a06
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Jul 16 03:48:11 2020 -0500
@201 - Put a lid on things after close.
---
.../core/src/java/org/apache/solr/cloud/ElectionContext.java | 2 +-
.../java/org/apache/solr/cloud/OverseerElectionContext.java | 4 ++++
.../org/apache/solr/cloud/ShardLeaderElectionContext.java | 12 ++++++++++--
solr/core/src/java/org/apache/solr/cloud/ZkController.java | 5 +++++
.../apache/solr/client/solrj/impl/BaseCloudSolrClient.java | 1 -
5 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
index 4eafa9f..6b64fba 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
@@ -33,7 +33,7 @@ public abstract class ElectionContext implements Closeable {
protected final String id;
protected final String leaderPath;
protected volatile String leaderSeqPath;
- private volatile boolean closed;
+ protected volatile boolean closed;
public ElectionContext(final String id, final String electionPath, final String leaderPath, final ZkNodeProps leaderProps) {
this.id = id;
diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/OverseerElectionContext.java
index 6092118..90ad43c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/OverseerElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerElectionContext.java
@@ -123,5 +123,9 @@ final class OverseerElectionContext extends ShardLeaderElectionContextBase {
public void checkIfIamLeaderFired() {
}
+
+ public boolean isClosed() {
+ return closed || overseer.getCoreContainer().isShutDown() || zkClient.isConnected() == false;
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
index 6940b10..bbf1afe 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
@@ -132,6 +132,10 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
@Override
void runLeaderProcess(ElectionContext context, boolean weAreReplacement, int pauseBeforeStart) throws KeeperException,
InterruptedException, IOException {
+ if (isClosed()) {
+ return;
+ }
+
String coreName = leaderProps.getStr(ZkStateReader.CORE_NAME_PROP);
ActionThrottle lt;
try (SolrCore core = cc.getCore(coreName)) {
@@ -161,7 +165,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
// throw new SolrException(ErrorCode.SERVER_ERROR, e1);
// }
- if (isClosed) {
+ if (isClosed()) {
// Solr is shutting down or the ZooKeeper session expired while waiting for replicas. If the later,
// we cannot be sure we are still the leader, so we should bail out. The OnReconnect handler will
// re-register the cores and handle a new leadership election.
@@ -192,7 +196,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
}
}
- if (isClosed) {
+ if (isClosed()) {
return;
}
@@ -435,5 +439,9 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
return collection;
}
+
+ public boolean isClosed() {
+ return closed || zkController.getCoreContainer().isShutDown() || zkController.getZkClient().isConnected() == false;
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 3c04f8f..f417389 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -1700,6 +1700,11 @@ public class ZkController implements Closeable {
}
}
MDCLoggingContext.setCoreDescriptor(cc, cd);
+
+ if ((state == Replica.State.ACTIVE || state == Replica.State.RECOVERING ) && isClosed()) {
+ throw new AlreadyClosedException();
+ }
+
try {
String collection = cd.getCloudDescriptor().getCollectionName();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index 0a1750d..cc69e38 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -932,7 +932,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
} catch (Exception exc) {
- System.out.println("IMHERE");
exc.printStackTrace();
Throwable rootCause = SolrException.getRootCause(exc);
// don't do retry support for admin requests