Skip to content

Apache Lucene open-source search software

SOLR-4624: remove leftover forceNew params.

Mark Robert Millerf6fa8c215dba
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8ddd2207193..46c88b07639 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -219,6 +219,8 @@ Bug Fixes
longer and it appears to be causing a missing close directory bug. forceNew
is no longer respected and will be removed in 4.3. (Mark Miller)
+* SOLR-4626: getIndexWriter(null) should also respect pauseWriter. (Mark Miller)
+
Optimizations
----------------------
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 2a33a904dc1..2368a227b3d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -409,7 +409,7 @@ public final class SolrCore implements SolrInfoMBean {
schema, coreDescriptor, updateHandler, this.solrDelPolicy, prev);
core.solrDelPolicy = this.solrDelPolicy;
- core.getUpdateHandler().getSolrCoreState().newIndexWriter(core, false, false);
+ core.getUpdateHandler().getSolrCoreState().newIndexWriter(core, false);
core.getSearcher(true, false, null, true);
diff --git a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
index 90e4612521e..d59d0c2869b 100644
--- a/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
+++ b/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
@@ -642,7 +642,7 @@ public class SnapPuller {
SolrQueryRequest req = new LocalSolrQueryRequest(solrCore,
new ModifiableSolrParams());
// reboot the writer on the new index and get a new searcher
- solrCore.getUpdateHandler().newIndexWriter(isFullCopyNeeded, false);
+ solrCore.getUpdateHandler().newIndexWriter(isFullCopyNeeded);
RefCounted<SolrIndexSearcher> searcher = null;
IndexCommit commitPoint;
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 bcf33b64f03..3a0fe82b52d 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -72,6 +72,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
log.info("closing IndexWriter...");
indexWriter.close();
}
+ indexWriter = null;
} catch (Throwable t) {
log.error("Error during shutdown of writer.", t);
}
@@ -86,13 +87,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
}
synchronized (writerPauseLock) {
- if (core == null) {
- // core == null is a signal to just return the current writer, or null
- // if none.
- if (refCntWriter != null) refCntWriter.incref();
- return refCntWriter;
- }
-
+
while (pauseWriter) {
try {
writerPauseLock.wait(100);
@@ -103,6 +98,14 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
}
}
+ if (core == null) {
+ // core == null is a signal to just return the current writer, or null
+ // if none.
+ if (refCntWriter != null) refCntWriter.incref();
+ return refCntWriter;
+ }
+
+
if (indexWriter == null) {
indexWriter = createMainIndexWriter(core, "DirectUpdateHandler2");
}
@@ -129,7 +132,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
}
@Override
- public synchronized void newIndexWriter(SolrCore core, boolean rollback, boolean forceNewDir) throws IOException {
+ public synchronized void newIndexWriter(SolrCore core, boolean rollback) throws IOException {
if (closed) {
throw new AlreadyClosedException("SolrCoreState already closed");
}
@@ -186,7 +189,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
@Override
public synchronized void rollbackIndexWriter(SolrCore core) throws IOException {
- newIndexWriter(core, true, false);
+ newIndexWriter(core, true);
}
protected SolrIndexWriter createMainIndexWriter(SolrCore core, String name) throws IOException {
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index f12f5c3a3bb..c0107042c2e 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -611,8 +611,8 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
}
@Override
- public void newIndexWriter(boolean rollback, boolean forceNewDir) throws IOException {
- solrCoreState.newIndexWriter(core, rollback, forceNewDir);
+ public void newIndexWriter(boolean rollback) throws IOException {
+ solrCoreState.newIndexWriter(core, rollback);
}
/**
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 12483736cff..738f2234f5c 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
@@ -86,7 +86,7 @@ public abstract class SolrCoreState {
* @param rollback close IndexWriter if false, else rollback
* @throws IOException If there is a low-level I/O error.
*/
- public abstract void newIndexWriter(SolrCore core, boolean rollback, boolean forceNewDir) throws IOException;
+ public abstract void newIndexWriter(SolrCore core, boolean rollback) throws IOException;
/**
* Get the current IndexWriter. If a new IndexWriter must be created, use the
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index ec4f72c966f..ad841342648 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -22,8 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.util.Vector;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrEventListener;
@@ -147,11 +145,10 @@ public abstract class UpdateHandler implements SolrInfoMBean {
* all of the index files.
*
* @param rollback IndexWriter if true else close
- * @param forceNewDir Force a new Directory instance
*
* @throws IOException If there is a low-level I/O error.
*/
- public abstract void newIndexWriter(boolean rollback, boolean forceNewDir) throws IOException;
+ public abstract void newIndexWriter(boolean rollback) throws IOException;
public abstract SolrCoreState getSolrCoreState();