This is an automated email from the ASF dual-hosted git repository. houston pushed a commit to branch add-pki-caching in repository https://gitbox.apache.org/repos/asf/solr.git
commit 3dd3a96f09c89f5d6a9f2915256aface46a4a8a0 Author: Jason Gerlowski <[email protected]> AuthorDate: Thu Oct 17 14:21:51 2024 -0400 SOLR-17413: ulog replay should copy SolrQueryRequest (#110) SolrQueryRequest is a non-threadsafe type, but was being shared across executor threads during UpdateLog replay. This introduces a number of issues, not the least being a ConcurrentModificationException if multiple threads happen to tweak the request 'context' simultaneously. This commit fixes this issue by giving each executor thread a unique LocalSolrQueryRequest instance to use. NOTE: This fix is on its way to 9.8 upstream, but may take a slightly different final form. Co-authored-by: Jason Gerlowski <[email protected]> --- solr/core/src/java/org/apache/solr/update/UpdateLog.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java index 4ebe4f311d1..609c4cefd31 100644 --- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java +++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java @@ -63,6 +63,7 @@ import org.apache.solr.common.SolrDocumentBase; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.CollectionUtil; @@ -2092,10 +2093,19 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer { UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(null); Collection<UpdateRequestProcessor> procPool = Collections.synchronizedList(new ArrayList<>()); + final var params = + new MapSolrParams( + Map.of( + DISTRIB_UPDATE_PARAM, + FROMLEADER.toString(), + DistributedUpdateProcessor.LOG_REPLAY, + "true")); ThreadLocal<UpdateRequestProcessor> procThreadLocal = ThreadLocal.withInitial( () -> { - var proc = processorChain.createProcessor(req, rsp); + // SolrQueryRequest is not thread-safe, so use a copy when creating URPs + final var localRequest = new LocalSolrQueryRequest(uhandler.core, params); + var proc = processorChain.createProcessor(localRequest, rsp); procPool.add(proc); return proc; });
