madrob commented on a change in pull request #2004:
URL: https://github.com/apache/lucene-solr/pull/2004#discussion_r507808511



##########
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:
       This is never used?

##########
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:
       How many contexts do we expect here. Does it actually make sense to do a 
parallel stream?

##########
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();

Review comment:
       This is in the shutdown path, should we add a timeout? What happens if a 
disk is slow on write and something else times out underneath us?

##########
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() {
+    this.pauseUpdateRequests.set(false);
+  }
+
+  /**
+   * Registers in-flight update requests to this core.
+   *
+   * @return true if request was registered, false if update requests are 
paused
+   */
+  public boolean registerInFlightUpdate() {
+    if (pauseUpdateRequests.get()) {
+      return false;
+    }
+    inflightUpdatesCounter.register();

Review comment:
       Do we need to check for termination?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to