SOLR-3938: prepareCommit command omits commitData

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1402373 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2012-10-26 02:00:44 +00:00
parent a74ae3ab2a
commit a6ea83ac30
3 changed files with 22 additions and 4 deletions

View File

@ -107,6 +107,9 @@ Bug Fixes
* SOLR-3920: Fix server list caching in CloudSolrServer when using more than one * SOLR-3920: Fix server list caching in CloudSolrServer when using more than one
collection list with the same instance. (Grzegorz Sobczyk, Mark Miller) 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 Other Changes
---------------------- ----------------------

View File

@ -447,7 +447,11 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
log.info("start "+cmd); log.info("start "+cmd);
RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core); RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
try { try {
iw.get().prepareCommit(); final Map<String,String> commitData = new HashMap<String,String>();
commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY,
String.valueOf(System.currentTimeMillis()));
iw.get().prepareCommit(commitData);
} finally { } finally {
iw.decref(); iw.decref();
} }

View File

@ -522,6 +522,17 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
for (int i = 0; i < nDocs; i++) for (int i = 0; i < nDocs; i++)
index(masterClient, "id", i, "name", "name = " + 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(); masterClient.commit();
NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient); NamedList masterQueryRsp = rQuery(nDocs, "*:*", masterClient);
@ -529,10 +540,10 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
assertEquals(nDocs, masterQueryResult.getNumFound()); assertEquals(nDocs, masterQueryResult.getNumFound());
// snappull // 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"; masterUrl += "http://127.0.0.1:" + masterJetty.getLocalPort() + "/solr/replication";
URL url = new URL(masterUrl); url = new URL(masterUrl);
InputStream stream = url.openStream(); stream = url.openStream();
try { try {
stream.close(); stream.close();
} catch (IOException e) { } catch (IOException e) {