Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Revert "SOLR-18083: Fix replication and other general operations in readOnly mode (#4081)"

Houston Putmanb314f8f5d357
diff --git a/changelog/unreleased/solr-18083-fix-read-only-behavior.yml b/changelog/unreleased/solr-18083-fix-read-only-behavior.yml
deleted file mode 100644
index 2aae02026c5..00000000000
--- a/changelog/unreleased/solr-18083-fix-read-only-behavior.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
-title: Fix operational issues with readOnly collections, such as restarting SolrNodes and replicating from the leader.
-type: fixed # added, changed, fixed, deprecated, removed, dependency_update, security, other
-authors:
- - name: Houston Putman
- nick: HoustonPutman
-links:
- - name: SOLR-18083
- url: https://issues.apache.org/jira/browse/SOLR-18083
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index bf023d3cb09..0b8c2a744da 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -303,8 +303,6 @@ public class RecoveryStrategy implements Runnable, Closeable {
// ureq.getParams().set(UpdateParams.OPEN_SEARCHER, onlyLeaderIndexes);
// Why do we need to open searcher if "onlyLeaderIndexes"?
ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
- // If the leader is readOnly, do not fail since the core is already committed.
- ureq.getParams().set(UpdateParams.FAIL_ON_READ_ONLY, false);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(client);
}
}
@@ -659,17 +657,15 @@ public class RecoveryStrategy implements Runnable, Closeable {
break;
}
- if (!core.readOnly) {
- // we wait a bit so that any updates on the leader
- // that started before they saw recovering state
- // are sure to have finished (see SOLR-7141 for
- // discussion around current value)
- // TODO since SOLR-11216, we probably won't need this
- try {
- Thread.sleep(waitForUpdatesWithStaleStatePauseMilliSeconds);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
+ // we wait a bit so that any updates on the leader
+ // that started before they saw recovering state
+ // are sure to have finished (see SOLR-7141 for
+ // discussion around current value)
+ // TODO since SOLR-11216, we probably won't need this
+ try {
+ Thread.sleep(waitForUpdatesWithStaleStatePauseMilliSeconds);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
// first thing we just try to sync
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 96401345503..16a29f89a58 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
@@ -195,7 +195,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
// first cancel any current recovery
core.getUpdateHandler().getSolrCoreState().cancelRecovery();
- if (weAreReplacement && !core.readOnly) {
+ if (weAreReplacement) {
// wait a moment for any floating updates to finish
try {
Thread.sleep(2500);
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 5e246e69ff1..24c7dc83b0c 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -2476,7 +2476,7 @@ public class SolrCore implements SolrInfoBean, Closeable {
true,
directoryFactory);
} else {
- RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this, true);
+ RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this);
DirectoryReader newReader = null;
try {
newReader = indexReaderFactory.newReader(writer.get(), this);
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 7e44992da16..70480602807 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -530,14 +530,14 @@ public class IndexFetcher {
// we just clear ours and commit
log.info("New index in Leader. Deleting mine...");
RefCounted<IndexWriter> iw =
- solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(solrCore, true);
+ solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(solrCore);
try {
iw.get().deleteAll();
} finally {
iw.decref();
}
assert TestInjection.injectDelayBeforeFollowerCommitRefresh();
- if (skipCommitOnLeaderVersionZero || solrCore.readOnly) {
+ if (skipCommitOnLeaderVersionZero) {
openNewSearcherAndUpdateCommitPoint();
} else {
SolrQueryRequest req = new LocalSolrQueryRequest(solrCore, new ModifiableSolrParams());
@@ -624,7 +624,7 @@ public class IndexFetcher {
// are successfully deleted
solrCore.getUpdateHandler().newIndexWriter(true);
RefCounted<IndexWriter> writer =
- solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(null, true);
+ solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(null);
try {
IndexWriter indexWriter = writer.get();
int c = 0;
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index 7f50064ffe1..cdc5de9313b 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -1378,7 +1378,7 @@ public class ReplicationHandler extends RequestHandlerBase
// ensure the writer is initialized so that we have a list of commit points
RefCounted<IndexWriter> iw =
- core.getUpdateHandler().getSolrCoreState().getIndexWriter(core, true);
+ core.getUpdateHandler().getSolrCoreState().getIndexWriter(core);
iw.decref();
} catch (IOException e) {
diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerUtils.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerUtils.java
index 7a04edad33e..7b5d791ae42 100644
--- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerUtils.java
+++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerUtils.java
@@ -99,7 +99,6 @@ public class RequestHandlerUtils {
cmd.maxOptimizeSegments =
params.getInt(UpdateParams.MAX_OPTIMIZE_SEGMENTS, cmd.maxOptimizeSegments);
cmd.prepareCommit = params.getBool(UpdateParams.PREPARE_COMMIT, cmd.prepareCommit);
- cmd.failOnReadOnly = params.getBool(UpdateParams.FAIL_ON_READ_ONLY, cmd.failOnReadOnly);
}
/**
diff --git a/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java b/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java
index 2e4d0be5fb2..6a749af2ac9 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java
@@ -39,7 +39,6 @@ public class CommitUpdateCommand extends UpdateCommand {
public boolean expungeDeletes = false;
public boolean softCommit = false;
public boolean prepareCommit = false;
- public boolean failOnReadOnly = true; // fail the commit if the core or collection is readOnly
/**
* User provided commit data. Can be let to null if there is none. It is possible to commit this
@@ -99,9 +98,6 @@ public class CommitUpdateCommand extends UpdateCommand {
.append(softCommit)
.append(",prepareCommit=")
.append(prepareCommit);
- if (!failOnReadOnly) {
- sb.append(",failOnReadOnly=").append(failOnReadOnly);
- }
if (commitData != null) {
sb.append(",commitData=").append(commitData);
}
diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
index 4feb43abd9d..767c1ad0b77 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -106,9 +106,8 @@ public final class DefaultSolrCoreState extends SolrCoreState
}
@Override
- public RefCounted<IndexWriter> getIndexWriter(SolrCore core, boolean readOnlyCompatible)
- throws IOException {
- if (core != null && (!core.indexEnabled || (!readOnlyCompatible && core.readOnly))) {
+ public RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException {
+ if (core != null && (!core.indexEnabled || core.readOnly)) {
throw new SolrException(
SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Indexing is temporarily disabled");
}
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
index 5016f9fdbb6..4d6f02d229f 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
@@ -178,19 +178,7 @@ public abstract class SolrCoreState {
*
* @throws IOException If there is a low-level I/O error.
*/
- 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)
- throws IOException;
+ public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException;
/**
* Rollback the current IndexWriter. When creating the new IndexWriter use the settings from the
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index fe6f44501e7..82424a5f06a 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -127,7 +127,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
protected final SolrQueryResponse rsp;
private final AtomicUpdateDocumentMerger docMerger;
- protected final UpdateLog ulog;
+ private final UpdateLog ulog;
private final VersionInfo vinfo;
private final boolean versionsStored;
private boolean returnVersions;
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
index 12c2695a29d..34532421bf5 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
@@ -161,15 +161,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
assert TestInjection.injectFailUpdateRequests();
if (isReadOnly()) {
- 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.
- assert ulog == null || !ulog.hasUncommittedChanges()
- : "Uncommitted changes found when trying to commit on a read-only collection";
- return;
- }
+ throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
}
List<SolrCmdDistributor.Node> nodes = null;
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/UpdateParams.java b/solr/solrj/src/java/org/apache/solr/common/params/UpdateParams.java
index df6b11f1f3a..f14252fb970 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/UpdateParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/UpdateParams.java
@@ -46,9 +46,6 @@ public interface UpdateParams {
/** expert: calls IndexWriter.prepareCommit */
public static String PREPARE_COMMIT = "prepareCommit";
- /** Fail a commit when the core or collection is in read-only mode */
- public static String FAIL_ON_READ_ONLY = "failOnReadOnly";
-
/** Rollback update commands */
public static String ROLLBACK = "rollback";