Skip to content

Apache Lucene open-source search software

SOLR-6273: Cross Data Center Replication: Fix at least one test, un-Ignore tests

Erick Ericksonf70464b15c8a
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 ea603da173d..a0a812dd0c5 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -80,6 +80,7 @@ import org.apache.solr.handler.ReplicationHandler.*;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.update.CdcrUpdateLog;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.UpdateLog;
import org.apache.solr.util.DefaultSolrThreadFactory;
@@ -808,7 +809,9 @@ public class IndexFetcher {
// this is called before copying the files to the original conf dir
// so that if there is an exception avoid corrupting the original files.
terminateAndWaitFsyncService();
+ ((CdcrUpdateLog) ulog).reset(); // reset the update log before copying the new tlog directory
copyTmpTlogFiles2Tlog(tmpTlogDir, timestamp);
+ ulog.init(solrCore.getUpdateHandler(), solrCore); // re-initialise the update log with the new directory
} finally {
delTree(tmpTlogDir);
}
diff --git a/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java b/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
index 32aa6f67526..6046eb6dd95 100644
--- a/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/CdcrUpdateLog.java
@@ -238,6 +238,30 @@ public class CdcrUpdateLog extends UpdateLog {
}
}
+ /**
+ * expert: Reset the update log before initialisation. This is needed by the IndexFetcher during a
+ * a Recovery operation in order to re-initialise the UpdateLog with a new set of tlog files.
+ */
+ public void reset() {
+ synchronized (this) {
+ // Close readers
+ for (CdcrLogReader reader : new ArrayList<>(logPointers.keySet())) {
+ reader.close();
+ }
+
+ // Close and clear logs
+ for (TransactionLog log : logs) {
+ log.deleteOnClose = false;
+ log.decref();
+ log.forceClose();
+ }
+ logs.clear();
+
+ // reset lastDataDir for #init()
+ lastDataDir = null;
+ }
+ }
+
@Override
public void close(boolean committed, boolean deleteOnClose) {
for (CdcrLogReader reader : new ArrayList<>(logPointers.keySet())) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationDistributedZkTest.java
index f9b198fbf74..bd103db05c5 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationDistributedZkTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-@Ignore
@Slow
public class CdcrReplicationDistributedZkTest extends BaseCdcrDistributedZkTest {
diff --git a/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationHandlerTest.java b/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationHandlerTest.java
index c6c8631aaf9..9f15804b5ab 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CdcrReplicationHandlerTest.java
@@ -32,7 +32,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-@Ignore
@Slow
public class CdcrReplicationHandlerTest extends BaseCdcrDistributedZkTest {
diff --git a/solr/core/src/test/org/apache/solr/cloud/CdcrRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/cloud/CdcrRequestHandlerTest.java
index f721512bde5..7c62c7ae97f 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CdcrRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CdcrRequestHandlerTest.java
@@ -23,7 +23,6 @@ import org.apache.solr.handler.CdcrParams;
import org.junit.Ignore;
import org.junit.Test;
-@Ignore
@Slow
public class CdcrRequestHandlerTest extends BaseCdcrDistributedZkTest {