shalinmangar commented on a change in pull request #2004:
URL: https://github.com/apache/lucene-solr/pull/2004#discussion_r508473215
##########
File path: solr/core/src/java/org/apache/solr/cloud/ZkController.java
##########
@@ -1838,6 +1838,22 @@ private void checkStateInZk(CoreDescriptor cd) throws
InterruptedException, NotI
}
}
+ public void tryCancelAllElections() {
+ if (zkClient.isClosed()) {
+ return;
+ }
+ electionContexts.values().parallelStream().forEach(context -> {
Review comment:
No, it does not. Parallelstream was being used for close in
ZkController.close() as well so this was basically copied code. However I
checked and it is a lightweight operation. It basically removes a zk node and
sets a volatile member. I have replaced this call with a serial forEach in both
places.
@hossman pointed out that this iteration wasn't safe so I have put the
forEach inside a synchronized block
##########
File path: solr/core/src/java/org/apache/solr/update/SolrCoreState.java
##########
@@ -86,7 +103,45 @@ public boolean decrefSolrCoreState(IndexWriterCloser
closer) {
}
return close;
}
-
+
+ /**
+ * Pauses all update requests to this core and waits (indefinitely) for all
in-flight
+ * update requests to finish
+ */
+ public void pauseUpdatesAndAwaitInflightRequests() {
+ if (pauseUpdateRequests.compareAndSet(false, true)) {
+ inflightUpdatesCounter.register();
+ inflightUpdatesCounter.arriveAndAwaitAdvance();
+ }
+ }
+
+ /**
+ * Unpauses update requests to this core
+ */
+ public void unpauseUpdates() {
Review comment:
Removed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]