You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:53:33 UTC

[lucene] 19/45: SOLR-13034: RTG sometimes didn't materialize LazyField (#2408)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 112e398d97d77f89bd2d114e569572d77536c290
Author: David Smiley <ds...@apache.org>
AuthorDate: Thu Feb 25 16:29:30 2021 -0500

    SOLR-13034: RTG sometimes didn't materialize LazyField (#2408)
    
    Partial (AKA Atomic) updates could encounter "LazyField" instances in the document
    cache and not know hot to deal with them when writing the updated doc to the update log.
    
    (cherry picked from commit 62971c4f990437e3ba4a5f4a2e980a058c2c01f1)
---
 solr/CHANGES.txt                                                    | 6 ++++++
 .../org/apache/solr/handler/component/RealTimeGetComponent.java     | 5 +++--
 .../test/org/apache/solr/update/processor/AtomicUpdatesTest.java    | 6 +++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 27e73e7..29598fe 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -45,8 +45,14 @@ Optimizations
 Bug Fixes
 ---------------------
 * SOLR-15078: Fix ExpandComponent behavior when expanding on numeric fields to differentiate '0' group from null group (hossman)
+
 * SOLR-15149: Better exception handling for LTR model creation errors (Alessandro Benedetti, Christine Poerschke)
 
+* SOLR-13034: Partial (AKA Atomic) updates could encounter "LazyField" instances in the document
+  cache and not know hot to deal with them when writing the updated doc to the update log.
+  (David Smiley)
+
+
 Other Changes
 ---------------------
 * SOLR-15118: Deprecate CollectionAdminRequest.getV2Request(). (Jason Gerlowski)
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 3e1ec93..8ae4dd3 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -822,8 +822,9 @@ public class RealTimeGetComponent extends SearchComponent
         if ((!sf.hasDocValues() && !sf.stored()) || schema.isCopyFieldTarget(sf)) continue;
       }
       for (Object val: doc.getFieldValues(fname)) {
-        if (val instanceof Field) {
-          Field f = (Field) val;
+        if (val instanceof IndexableField) {
+          IndexableField f = (IndexableField) val;
+          // materialize:
           if (sf != null) {
             val = sf.getType().toObject(f);   // object or external string?
           } else {
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
index 3eba208..fcedc1f 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdatesTest.java
@@ -1005,7 +1005,11 @@ public class AtomicUpdatesTest extends SolrTestCaseJ4 {
 
     assertU(commit());
 
-    assertQ(req("q", "cat:*", "indent", "true"), "//result[@numFound = '2']");
+    // note: by requesting only the id, the other field values will be LazyField instances in the
+    // document cache.
+    // This winds up testing that future fetches by RTG of this doc will handle it properly.
+    // See SOLR-13034
+    assertQ(req("q", "cat:*", "indent", "true", "fl", "id"), "//result[@numFound = '2']");
     assertQ(req("q", "cat:bbb", "indent", "true"), "//result[@numFound = '0']");