dsmiley commented on code in PR #4081:
URL: https://github.com/apache/solr/pull/4081#discussion_r2737798943


##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -2476,7 +2476,7 @@ public RefCounted<SolrIndexSearcher> openNewSearcher(
                   true,
                   directoryFactory);
         } else {
-          RefCounted<IndexWriter> writer = 
getSolrCoreState().getIndexWriter(this);
+          RefCounted<IndexWriter> writer = 
getSolrCoreState().getIndexWriter(this, true);

Review Comment:
   why?



##########
solr/core/src/java/org/apache/solr/update/SolrCoreState.java:
##########
@@ -178,7 +178,19 @@ public void deregisterInFlightUpdate() {
    *
    * @throws IOException If there is a low-level I/O error.
    */
-  public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws 
IOException;
+  public RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws 
IOException {
+    return getIndexWriter(core, false);
+  }
+
+  /**
+   * Get the current IndexWriter. If a new IndexWriter must be created, use 
the settings from the
+   * given {@link SolrCore}. Be very careful using the {@code 
readOnlyCompatible} flag, by default
+   * it should be false if the returned indexWriter will be used for writing.
+   *
+   * @throws IOException If there is a low-level I/O error.
+   */
+  public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core, 
boolean readOnlyCompatible)

Review Comment:
   `readOnlyCompatible` is a clumsy name to me... I draw a blank and have to 
think about what you mean.  How about `ignoreReadOnly` ?



##########
solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java:
##########
@@ -97,7 +98,9 @@ public String toString() {
             .append(",softCommit=")
             .append(softCommit)
             .append(",prepareCommit=")
-            .append(prepareCommit);
+            .append(prepareCommit)
+            .append(",failOnReadOnly=")

Review Comment:
   can we do this conditionally please?



##########
solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java:
##########
@@ -161,7 +161,13 @@ public void processCommit(CommitUpdateCommand cmd) throws 
IOException {
     assert TestInjection.injectFailUpdateRequests();
 
     if (isReadOnly()) {
-      throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection 
+ " is read-only.");
+      if (cmd.failOnReadOnly) {
+        throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + 
collection + " is read-only.");
+      } else {
+        // Committing on a readOnly core/collection is a no-op, since the core 
was committed when
+        // becoming read-only and hasn't had any updates since.

Review Comment:
   could we actually assert this -- like the same check Solr does to avoid 
committing if there's nothing to do?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to