Skip to content

Commit b314f8f

Browse files
committed
Revert "SOLR-18083: Fix replication and other general operations in readOnly mode (#4081)"
This reverts commit f9bdca8.
1 parent f9bdca8 commit b314f8f

File tree

13 files changed

+20
-62
lines changed

13 files changed

+20
-62
lines changed

changelog/unreleased/solr-18083-fix-read-only-behavior.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ private void commitOnLeader(String leaderBaseUrl, String coreName)
303303
// ureq.getParams().set(UpdateParams.OPEN_SEARCHER, onlyLeaderIndexes);
304304
// Why do we need to open searcher if "onlyLeaderIndexes"?
305305
ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
306-
// If the leader is readOnly, do not fail since the core is already committed.
307-
ureq.getParams().set(UpdateParams.FAIL_ON_READ_ONLY, false);
308306
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(client);
309307
}
310308
}
@@ -659,17 +657,15 @@ public final void doSyncOrReplicateRecovery(SolrCore core) throws Exception {
659657
break;
660658
}
661659

662-
if (!core.readOnly) {
663-
// we wait a bit so that any updates on the leader
664-
// that started before they saw recovering state
665-
// are sure to have finished (see SOLR-7141 for
666-
// discussion around current value)
667-
// TODO since SOLR-11216, we probably won't need this
668-
try {
669-
Thread.sleep(waitForUpdatesWithStaleStatePauseMilliSeconds);
670-
} catch (InterruptedException e) {
671-
Thread.currentThread().interrupt();
672-
}
660+
// we wait a bit so that any updates on the leader
661+
// that started before they saw recovering state
662+
// are sure to have finished (see SOLR-7141 for
663+
// discussion around current value)
664+
// TODO since SOLR-11216, we probably won't need this
665+
try {
666+
Thread.sleep(waitForUpdatesWithStaleStatePauseMilliSeconds);
667+
} catch (InterruptedException e) {
668+
Thread.currentThread().interrupt();
673669
}
674670

675671
// first thing we just try to sync

solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void runLeaderProcess(boolean weAreReplacement) throws KeeperException, Interrup
195195
// first cancel any current recovery
196196
core.getUpdateHandler().getSolrCoreState().cancelRecovery();
197197

198-
if (weAreReplacement && !core.readOnly) {
198+
if (weAreReplacement) {
199199
// wait a moment for any floating updates to finish
200200
try {
201201
Thread.sleep(2500);

solr/core/src/java/org/apache/solr/core/SolrCore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ public RefCounted<SolrIndexSearcher> openNewSearcher(
24762476
true,
24772477
directoryFactory);
24782478
} else {
2479-
RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this, true);
2479+
RefCounted<IndexWriter> writer = getSolrCoreState().getIndexWriter(this);
24802480
DirectoryReader newReader = null;
24812481
try {
24822482
newReader = indexReaderFactory.newReader(writer.get(), this);

solr/core/src/java/org/apache/solr/handler/IndexFetcher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,14 @@ IndexFetchResult fetchLatestIndex(boolean forceReplication, boolean forceCoreRel
530530
// we just clear ours and commit
531531
log.info("New index in Leader. Deleting mine...");
532532
RefCounted<IndexWriter> iw =
533-
solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(solrCore, true);
533+
solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(solrCore);
534534
try {
535535
iw.get().deleteAll();
536536
} finally {
537537
iw.decref();
538538
}
539539
assert TestInjection.injectDelayBeforeFollowerCommitRefresh();
540-
if (skipCommitOnLeaderVersionZero || solrCore.readOnly) {
540+
if (skipCommitOnLeaderVersionZero) {
541541
openNewSearcherAndUpdateCommitPoint();
542542
} else {
543543
SolrQueryRequest req = new LocalSolrQueryRequest(solrCore, new ModifiableSolrParams());
@@ -624,7 +624,7 @@ IndexFetchResult fetchLatestIndex(boolean forceReplication, boolean forceCoreRel
624624
// are successfully deleted
625625
solrCore.getUpdateHandler().newIndexWriter(true);
626626
RefCounted<IndexWriter> writer =
627-
solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(null, true);
627+
solrCore.getUpdateHandler().getSolrCoreState().getIndexWriter(null);
628628
try {
629629
IndexWriter indexWriter = writer.get();
630630
int c = 0;

solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ public void inform(SolrCore core) {
13781378

13791379
// ensure the writer is initialized so that we have a list of commit points
13801380
RefCounted<IndexWriter> iw =
1381-
core.getUpdateHandler().getSolrCoreState().getIndexWriter(core, true);
1381+
core.getUpdateHandler().getSolrCoreState().getIndexWriter(core);
13821382
iw.decref();
13831383

13841384
} catch (IOException e) {

solr/core/src/java/org/apache/solr/handler/RequestHandlerUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public static void updateCommit(CommitUpdateCommand cmd, SolrParams params) {
9999
cmd.maxOptimizeSegments =
100100
params.getInt(UpdateParams.MAX_OPTIMIZE_SEGMENTS, cmd.maxOptimizeSegments);
101101
cmd.prepareCommit = params.getBool(UpdateParams.PREPARE_COMMIT, cmd.prepareCommit);
102-
cmd.failOnReadOnly = params.getBool(UpdateParams.FAIL_ON_READ_ONLY, cmd.failOnReadOnly);
103102
}
104103

105104
/**

solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class CommitUpdateCommand extends UpdateCommand {
3939
public boolean expungeDeletes = false;
4040
public boolean softCommit = false;
4141
public boolean prepareCommit = false;
42-
public boolean failOnReadOnly = true; // fail the commit if the core or collection is readOnly
4342

4443
/**
4544
* User provided commit data. Can be let to null if there is none. It is possible to commit this
@@ -99,9 +98,6 @@ public String toString() {
9998
.append(softCommit)
10099
.append(",prepareCommit=")
101100
.append(prepareCommit);
102-
if (!failOnReadOnly) {
103-
sb.append(",failOnReadOnly=").append(failOnReadOnly);
104-
}
105101
if (commitData != null) {
106102
sb.append(",commitData=").append(commitData);
107103
}

solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ private void closeIndexWriter(IndexWriterCloser closer) {
106106
}
107107

108108
@Override
109-
public RefCounted<IndexWriter> getIndexWriter(SolrCore core, boolean readOnlyCompatible)
110-
throws IOException {
111-
if (core != null && (!core.indexEnabled || (!readOnlyCompatible && core.readOnly))) {
109+
public RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException {
110+
if (core != null && (!core.indexEnabled || core.readOnly)) {
112111
throw new SolrException(
113112
SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Indexing is temporarily disabled");
114113
}

solr/core/src/java/org/apache/solr/update/SolrCoreState.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,7 @@ public void deregisterInFlightUpdate() {
178178
*
179179
* @throws IOException If there is a low-level I/O error.
180180
*/
181-
public RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException {
182-
return getIndexWriter(core, false);
183-
}
184-
185-
/**
186-
* Get the current IndexWriter. If a new IndexWriter must be created, use the settings from the
187-
* given {@link SolrCore}. Be very careful using the {@code readOnlyCompatible} flag, by default
188-
* it should be false if the returned indexWriter will be used for writing.
189-
*
190-
* @throws IOException If there is a low-level I/O error.
191-
*/
192-
public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core, boolean readOnlyCompatible)
193-
throws IOException;
181+
public abstract RefCounted<IndexWriter> getIndexWriter(SolrCore core) throws IOException;
194182

195183
/**
196184
* Rollback the current IndexWriter. When creating the new IndexWriter use the settings from the

0 commit comments

Comments
 (0)