mirror of https://github.com/apache/lucene.git
SOLR-12083: Fix RealTime GET to work on a cluster running CDCR when using Solr's in-place updates
This commit is contained in:
parent
b7793372a9
commit
57524f1d41
|
@ -318,6 +318,9 @@ Bug Fixes
|
||||||
* SOLR-12064: JSON Facet API: fix bug where a limit of -1 in conjunction with multiple facets or
|
* SOLR-12064: JSON Facet API: fix bug where a limit of -1 in conjunction with multiple facets or
|
||||||
missing=true caused an NPE or AIOOBE. (Karthik Ramachandran via yonik)
|
missing=true caused an NPE or AIOOBE. (Karthik Ramachandran via yonik)
|
||||||
|
|
||||||
|
* SOLR-12083: Fix RealTime GET to work on a cluster running CDCR when using Solr's in-place updates
|
||||||
|
(Amrit Sarkar, Varun Thacker)
|
||||||
|
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -80,6 +80,7 @@ import org.apache.solr.search.SolrDocumentFetcher;
|
||||||
import org.apache.solr.search.SolrIndexSearcher;
|
import org.apache.solr.search.SolrIndexSearcher;
|
||||||
import org.apache.solr.search.SolrReturnFields;
|
import org.apache.solr.search.SolrReturnFields;
|
||||||
import org.apache.solr.search.SyntaxError;
|
import org.apache.solr.search.SyntaxError;
|
||||||
|
import org.apache.solr.update.CdcrUpdateLog;
|
||||||
import org.apache.solr.update.DocumentBuilder;
|
import org.apache.solr.update.DocumentBuilder;
|
||||||
import org.apache.solr.update.IndexFingerprint;
|
import org.apache.solr.update.IndexFingerprint;
|
||||||
import org.apache.solr.update.PeerSync;
|
import org.apache.solr.update.PeerSync;
|
||||||
|
@ -255,7 +256,11 @@ public class RealTimeGetComponent extends SearchComponent
|
||||||
if (oper == UpdateLog.ADD) {
|
if (oper == UpdateLog.ADD) {
|
||||||
doc = toSolrDoc((SolrInputDocument)entry.get(entry.size()-1), core.getLatestSchema());
|
doc = toSolrDoc((SolrInputDocument)entry.get(entry.size()-1), core.getLatestSchema());
|
||||||
} else if (oper == UpdateLog.UPDATE_INPLACE) {
|
} else if (oper == UpdateLog.UPDATE_INPLACE) {
|
||||||
assert entry.size() == 5;
|
if (ulog instanceof CdcrUpdateLog) {
|
||||||
|
assert entry.size() == 6;
|
||||||
|
} else {
|
||||||
|
assert entry.size() == 5;
|
||||||
|
}
|
||||||
// For in-place update case, we have obtained the partial document till now. We need to
|
// For in-place update case, we have obtained the partial document till now. We need to
|
||||||
// resolve it to a full document to be returned to the user.
|
// resolve it to a full document to be returned to the user.
|
||||||
doc = resolveFullDocument(core, idBytes.get(), rsp.getReturnFields(), (SolrInputDocument)entry.get(entry.size()-1), entry, null);
|
doc = resolveFullDocument(core, idBytes.get(), rsp.getReturnFields(), (SolrInputDocument)entry.get(entry.size()-1), entry, null);
|
||||||
|
@ -395,7 +400,7 @@ public class RealTimeGetComponent extends SearchComponent
|
||||||
*/
|
*/
|
||||||
private static SolrDocument resolveFullDocument(SolrCore core, BytesRef idBytes,
|
private static SolrDocument resolveFullDocument(SolrCore core, BytesRef idBytes,
|
||||||
ReturnFields returnFields, SolrInputDocument partialDoc, List logEntry, Set<String> onlyTheseFields) throws IOException {
|
ReturnFields returnFields, SolrInputDocument partialDoc, List logEntry, Set<String> onlyTheseFields) throws IOException {
|
||||||
if (idBytes == null || logEntry.size() != 5) {
|
if (idBytes == null || (logEntry.size() != 5 && logEntry.size() != 6)) {
|
||||||
throw new SolrException(ErrorCode.INVALID_STATE, "Either Id field not present in partial document or log entry doesn't have previous version.");
|
throw new SolrException(ErrorCode.INVALID_STATE, "Either Id field not present in partial document or log entry doesn't have previous version.");
|
||||||
}
|
}
|
||||||
long prevPointer = (long) logEntry.get(UpdateLog.PREV_POINTER_IDX);
|
long prevPointer = (long) logEntry.get(UpdateLog.PREV_POINTER_IDX);
|
||||||
|
@ -541,7 +546,11 @@ public class RealTimeGetComponent extends SearchComponent
|
||||||
}
|
}
|
||||||
switch (oper) {
|
switch (oper) {
|
||||||
case UpdateLog.UPDATE_INPLACE:
|
case UpdateLog.UPDATE_INPLACE:
|
||||||
assert entry.size() == 5;
|
if (ulog instanceof CdcrUpdateLog) {
|
||||||
|
assert entry.size() == 6;
|
||||||
|
} else {
|
||||||
|
assert entry.size() == 5;
|
||||||
|
}
|
||||||
|
|
||||||
if (resolveFullDocument) {
|
if (resolveFullDocument) {
|
||||||
SolrInputDocument doc = (SolrInputDocument)entry.get(entry.size()-1);
|
SolrInputDocument doc = (SolrInputDocument)entry.get(entry.size()-1);
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</peerSync>
|
</peerSync>
|
||||||
|
|
||||||
<updateHandler class="solr.DirectUpdateHandler2">
|
<updateHandler class="solr.DirectUpdateHandler2">
|
||||||
<updateLog>
|
<updateLog class="${solr.tests.ulog:solr.UpdateLog}">
|
||||||
<str name="dir">${solr.ulog.dir:}</str>
|
<str name="dir">${solr.ulog.dir:}</str>
|
||||||
<str name="maxNumLogsToKeep">${solr.ulog.maxNumLogsToKeep:10}</str>
|
<str name="maxNumLogsToKeep">${solr.ulog.maxNumLogsToKeep:10}</str>
|
||||||
<str name="numRecordsToKeep">${solr.ulog.numRecordsToKeep:100}</str>
|
<str name="numRecordsToKeep">${solr.ulog.numRecordsToKeep:100}</str>
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class TestRealTimeGet extends TestRTGBase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
|
randomizeUpdateLogImpl();
|
||||||
initCore("solrconfig-tlog.xml","schema_latest.xml");
|
initCore("solrconfig-tlog.xml","schema_latest.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
|
||||||
// asserting inplace updates happen by checking the internal [docid]
|
// asserting inplace updates happen by checking the internal [docid]
|
||||||
systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
|
systemSetPropertySolrTestsMergePolicyFactory(NoMergePolicyFactory.class.getName());
|
||||||
|
|
||||||
|
randomizeUpdateLogImpl();
|
||||||
|
|
||||||
initCore(configString, schemaString);
|
initCore(configString, schemaString);
|
||||||
|
|
||||||
// sanity check that autocommits are disabled
|
// sanity check that autocommits are disabled
|
||||||
|
|
|
@ -802,6 +802,11 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
System.clearProperty("solr.directoryFactory");
|
System.clearProperty("solr.directoryFactory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (System.getProperty(UPDATELOG_SYSPROP) != null) {
|
||||||
|
// clears the updatelog sysprop at the end of the test run
|
||||||
|
System.clearProperty(UPDATELOG_SYSPROP);
|
||||||
|
}
|
||||||
|
|
||||||
solrConfig = null;
|
solrConfig = null;
|
||||||
h = null;
|
h = null;
|
||||||
lrf = null;
|
lrf = null;
|
||||||
|
@ -2704,6 +2709,20 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
*/
|
*/
|
||||||
public static final String NUMERIC_DOCVALUES_SYSPROP = "solr.tests.numeric.dv";
|
public static final String NUMERIC_DOCVALUES_SYSPROP = "solr.tests.numeric.dv";
|
||||||
|
|
||||||
|
public static final String UPDATELOG_SYSPROP = "solr.tests.ulog";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* randomizes the updateLog between different update log implementations for better test coverage
|
||||||
|
*/
|
||||||
|
public static void randomizeUpdateLogImpl() {
|
||||||
|
if (random().nextBoolean()) {
|
||||||
|
System.setProperty(UPDATELOG_SYSPROP, "solr.CdcrUpdateLog");
|
||||||
|
} else {
|
||||||
|
System.setProperty(UPDATELOG_SYSPROP,"solr.UpdateLog");
|
||||||
|
}
|
||||||
|
log.info("updateLog impl={}", System.getProperty(UPDATELOG_SYSPROP));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets various sys props related to user specified or randomized choices regarding the types
|
* Sets various sys props related to user specified or randomized choices regarding the types
|
||||||
* of numerics that should be used in tests.
|
* of numerics that should be used in tests.
|
||||||
|
|
Loading…
Reference in New Issue