You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2016/08/30 19:50:35 UTC
lucene-solr:branch_6x: SOLR-9447: Do not clone SolrInputDocument if
update processor chain does not contain custom processors. (cherry picked
from commit 26262f4)
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 6bf9513b9 -> 65c2cf3a0
SOLR-9447: Do not clone SolrInputDocument if update processor chain does not contain custom processors.
(cherry picked from commit 26262f4)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/65c2cf3a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/65c2cf3a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/65c2cf3a
Branch: refs/heads/branch_6x
Commit: 65c2cf3a0a260d571d0da7c50fb8295f1473b9a3
Parents: 6bf9513
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Wed Aug 31 01:19:42 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Wed Aug 31 01:20:25 2016 +0530
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../processor/DistributedUpdateProcessor.java | 22 ++++++++++++++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65c2cf3a/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 844214a..d26f4c6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -66,6 +66,9 @@ Optimizations
* SOLR-9449: Example schemas do not index _version_ field anymore because the field
has DocValues enabled already. (shalin)
+* SOLR-9447: Do not clone SolrInputDocument if update processor chain does not contain custom processors.
+ (shalin)
+
Other Changes
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65c2cf3a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index f19352d..b8bdd16 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -266,6 +266,11 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
//used for keeping track of replicas that have processed an add/update from the leader
private RequestReplicationTracker replicationTracker = null;
+ // should we clone the document before sending it to replicas?
+ // this is set to true in the constructor if the next processors in the chain
+ // are custom and may modify the SolrInputDocument racing with its serialization for replication
+ private final boolean cloneRequiredOnLeader;
+
public DistributedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
this(req, rsp, new AtomicUpdateDocumentMerger(req), next);
}
@@ -314,6 +319,19 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
collection = null;
}
+ boolean shouldClone = false;
+ UpdateRequestProcessor nextInChain = next;
+ while (nextInChain != null) {
+ Class<? extends UpdateRequestProcessor> klass = nextInChain.getClass();
+ if (klass != LogUpdateProcessorFactory.LogUpdateProcessor.class
+ && klass != RunUpdateProcessor.class
+ && klass != TolerantUpdateProcessor.class) {
+ shouldClone = true;
+ break;
+ }
+ nextInChain = nextInChain.next;
+ }
+ cloneRequiredOnLeader = shouldClone;
}
private List<Node> setupRequest(String id, SolrInputDocument doc) {
@@ -1086,14 +1104,14 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
boolean willDistrib = isLeader && nodes != null && nodes.size() > 0;
SolrInputDocument clonedDoc = null;
- if (willDistrib) {
+ if (willDistrib && cloneRequiredOnLeader) {
clonedDoc = cmd.solrDoc.deepCopy();
}
// TODO: possibly set checkDeleteByQueries as a flag on the command?
doLocalAdd(cmd);
- if (willDistrib) {
+ if (willDistrib && cloneRequiredOnLeader) {
cmd.solrDoc = clonedDoc;
}