Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-4246: log forwarded updates

Yonik Seeley9e82c2409d62
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1e37dfbb423..618e54e3747 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -178,6 +178,11 @@ New Features
these allow cores to be loaded only when needed and only transientCacheSize transient
cores will be loaded at a time, the rest aged out on an LRU basis.
+* SOLR-4246: When update.distrib is set to skip update processors before
+ the distributed update processor, always include the log update processor
+ so forwarded updates will still be logged. (yonik)
+
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
index 2fd50d73b73..282549bdb3a 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java
@@ -145,8 +145,7 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
* If the <code>DISTRIB_UPDATE_PARAM</code> is present in the request and is
* non-blank, then any factory in this chain prior to the instance of
* <code>{@link DistributingUpdateProcessorFactory}</code> will be skipped,
- * and the <code>UpdateRequestProcessor</code> returned will be from that
- * <code>DistributingUpdateProcessorFactory</code>
+ * except for the log update processor factory.
*
* @see UpdateRequestProcessorFactory#getInstance
* @see DistributingUpdateProcessorFactory#DISTRIB_UPDATE_PARAM
@@ -157,18 +156,28 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
UpdateRequestProcessor processor = null;
UpdateRequestProcessor last = null;
- final String distribPhase = req.getParams().get
- (DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM, "");
- final boolean skipToDistrib = ! distribPhase.trim().isEmpty();
+ final String distribPhase = req.getParams().get(DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM);
+ final boolean skipToDistrib = distribPhase != null;
+ boolean afterDistrib = true; // we iterate backwards, so true to start
for (int i = chain.length-1; i>=0; i--) {
- processor = chain[i].getInstance(req, rsp, last);
- last = processor == null ? last : processor;
- if (skipToDistrib
- && chain[i] instanceof DistributingUpdateProcessorFactory) {
- break;
+ UpdateRequestProcessorFactory factory = chain[i];
+
+ if (skipToDistrib) {
+ if (afterDistrib) {
+ if (factory instanceof DistributingUpdateProcessorFactory) {
+ afterDistrib = false;
+ }
+ } else if (!(factory instanceof LogUpdateProcessorFactory)) { // TODO: use a marker interface for this?
+ // skip anything that is not the log factory
+ continue;
+ }
}
+
+ processor = factory.getInstance(req, rsp, last);
+ last = processor == null ? last : processor;
}
+
return last;
}