From a6ea83ac30af5ef4fb903e5cb4b10e2cb56bd724 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 26 Oct 2012 02:00:44 +0000 Subject: [PATCH] SOLR-3938: prepareCommit command omits commitData git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1402373 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../solr/update/DirectUpdateHandler2.java | 6 +++++- .../solr/handler/TestReplicationHandler.java | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8c56ab57fbb..e4cd6cdda96 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -107,6 +107,9 @@ Bug Fixes * SOLR-3920: Fix server list caching in CloudSolrServer when using more than one collection list with the same instance. (Grzegorz Sobczyk, Mark Miller) +* SOLR-3938: prepareCommit command omits commitData causing a failure to trigger + replication to slaves. (yonik) + Other Changes ---------------------- 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 d6906146d75..18654d63f39 100644 --- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java +++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java @@ -447,7 +447,11 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState log.info("start "+cmd); RefCounted iw = solrCoreState.getIndexWriter(core); try { - iw.get().prepareCommit(); + final Map commitData = new HashMap(); + commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY, + String.valueOf(System.currentTimeMillis())); + + iw.get().prepareCommit(commitData); } finally { iw.decref(); } diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java index 1df858caafc..39ada38b249 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -522,6 +522,17 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { for (int i = 0; i < nDocs; i++) index(masterClient, "id", i, "name", "name = " + i); + // make sure prepareCommit doesn't mess up commit (SOLR-3938) + // todo: make SolrJ easier to pass arbitrary params to + String masterUrl = "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/update?prepareCommit=true"; + URL url = new URL(masterUrl); + InputStream stream = url.openStream(); + try { + stream.close(); + } catch (IOException e) { + //e.printStackTrace(); + } + masterClient.commit(); NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient); @@ -529,10 +540,10 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { assertEquals(nDocs, masterQueryResult.getNumFound()); // snappull - String masterUrl = "http://127.0.0.1:" + slaveJetty.getLocalPort() + "/solr/replication?command=fetchindex&masterUrl="; + masterUrl = "http://127.0.0.1:" + slaveJetty.getLocalPort() + "/solr/replication?command=fetchindex&masterUrl="; masterUrl += "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication"; - URL url = new URL(masterUrl); - InputStream stream = url.openStream(); + url = new URL(masterUrl); + stream = url.openStream(); try { stream.close(); } catch (IOException e) {