<div dir="ltr"><div>Hi all,</div><div><br></div><div>I&#39;m really struggling with something in order to finish the compute methods.</div><div><br></div><div>I added a test in <b>ClusteredCacheWithElasticsearchIndexManagerIT</b></div><div><br></div><div><pre style="color:rgb(0,0,0);font-family:menlo;font-size:9pt"><pre style="font-family:menlo;font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">public void </span>testToto() <span style="color:rgb(0,0,128);font-weight:bold">throws </span>Exception {<br>    SearchManager searchManager = Search.<span style="font-style:italic">getSearchManager</span>(<span style="color:rgb(102,14,122);font-weight:bold">cache2</span>);<br>    QueryBuilder queryBuilder = searchManager<br>          .buildQueryBuilderForClass(Person.<span style="color:rgb(0,0,128);font-weight:bold">class</span>)<br>          .get();<br>    Query allQuery = queryBuilder.all().createQuery();<br><br>    String key = <span style="color:rgb(0,128,0);font-weight:bold">&quot;newGoat&quot;</span>;<br>    Person person4 = <span style="color:rgb(0,0,128);font-weight:bold">new </span>Person(key, <span style="color:rgb(0,128,0);font-weight:bold">&quot;eats something&quot;</span>, <span style="color:rgb(0,0,255)">42</span>);<br><br>    <span style="color:rgb(102,14,122);font-weight:bold">cache2</span>.putIfAbsent(key, person4);<br>    StaticTestingErrorHandler.<span style="font-style:italic">assertAllGood</span>(<span style="color:rgb(102,14,122);font-weight:bold">cache1</span>, <span style="color:rgb(102,14,122);font-weight:bold">cache2</span>);<br><br>    List&lt;Person&gt; found = searchManager.&lt;Person&gt;getQuery(allQuery, Person.<span style="color:rgb(0,0,128);font-weight:bold">class</span>).list();<br>    <span style="font-style:italic">assertEquals</span>(<span style="color:rgb(0,0,255)">1</span>, found.size());<br>    <span style="font-style:italic">assertTrue</span>(found.contains(person4));<br>}</pre></pre></div><div><div>I put some logs in the <span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-family:menlo;font-size:9pt">processPutKeyValueCommand </span>method in the <b>QueryInterceptor</b> to explain what is happening.<br></div><div><br></div><div><b>2 threads</b></div><div>Sometimes two threads get involved. </div><div><br></div><div>= Thread 72 First (or second) call </div><div>It happens from a non local Node. The so the <span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-family:menlo;font-size:9pt">shouldModifyIndexes </span>says &quot;no, you should not modify any index&quot; because the <span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-family:menlo;font-size:9pt">IndexModificationStrategy</span> is set to &quot;LOCAL ONLY&quot;. [1]<br></div><div><br></div><div><div><font face="monospace, monospace">72 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeB-19565</font></div><div><font face="monospace, monospace">72 should modify false</font></div><div><font face="monospace, monospace">72 previousValue null</font></div><div><font face="monospace, monospace">72 putValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null} // value in the command</font></div><div><font face="monospace, monospace">72 contextValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null} //value in the invocation context</font></div></div><div><br></div><div>= Thread 48 Second (or first) call</div><div>the origin is null, and this is considered as a LOCAL in the <span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-family:menlo;font-size:9pt">SingleKeyNonTxInvocationContext. [2]</span> In this case, the index is modified correctly, the value in the context has already been set up by the PutKeyValueCommand and the index get&#39;s correctly updated.</div><div><br></div><div><div><font face="monospace, monospace">48 ctx.getOrigin() = null</font></div><div><font face="monospace, monospace">48 should modify true</font></div><div><font face="monospace, monospace">48 previousValue null</font></div><div><font face="monospace, monospace">48 putValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace">48 contextValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div></div><div><br></div><div>And everything is ok. Everything is fine too in the case of a compute method instead of the put method.</div><div><br></div><div>But sometimes, this is not executed like that.</div></div><div><br></div><div><div><b>3 threads</b></div></div><div><b><br></b></div><div><div>What is a bit more weird to me is this second scenario where the commands are executed both from non local nodes (A and B). And so the index is not updated.</div><div>But  just later, another thread get&#39;s involved and calls the QueryInterceptor with a invocation context where the command has not been executed (the value is not inside the context and the debugger does not enter in the perform method, this has happened just twice before). This call is coming like from a callback? in the <span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-family:menlo;font-size:9pt">QueueAsyncInvocationStage.</span></div></div><div><span style="background-color:rgb(228,228,255);color:rgb(0,0,0);font-size:9pt"><font face="monospace, monospace"><br></font></span></div><div><div><font face="monospace, monospace">80 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeA-65110</font></div><div><font face="monospace, monospace">80 should modify false</font></div><div><font face="monospace, monospace">80 prev null</font></div><div><font face="monospace, monospace">80 putValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace">80 contextValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">38 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeB-35919</font></div><div><font face="monospace, monospace">38 should modify false</font></div><div><font face="monospace, monospace">38 prev null</font></div><div><font face="monospace, monospace">38 putValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace">38 contextValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">48 ctx.getOrigin() = null</font></div><div><font face="monospace, monospace">48 should modify true</font></div><div><font face="monospace, monospace">48 prev null</font></div><div><font face="monospace, monospace">48 putValue Person{name=&#39;newGoat&#39;, blurb=&#39;eats something&#39;, age=42, dateOfGraduation=null}</font></div><div><font face="monospace, monospace" color="#ff0000">48 contextValue null</font></div></div><div><br></div><div><br></div><div>This execution works perfectly with PutKeyValueCommand. But don&#39;t work wth compute.</div><div><br></div><div>The &quot;computed value&quot; is not inside the Command like put, replace or others. It is computed in the perform method (if needed). So, the first time the command is executed in A, the computed value is in the context, but the index is not updated. Second call, executed in B, value in context, but the index is not updated. The magic callback is executed, but the computed value is nowhere because the command is not executed a third time, so the context is null.<br></div><div><br></div><div>Can somebody please give me some light on this and explain to me what am I missing ? Other tests are failing for the same problem, like org.infinispan.query.blackbox.ClusteredCacheWithInfinispanDirectoryTest</div><div><br></div><div>Thank you very much for your help !</div><div><br></div><div>Katia</div><div><br></div><div>[1] <a href="https://github.com/infinispan/infinispan/blob/master/query/src/main/java/org/infinispan/query/backend/IndexModificationStrategy.java#L50">https://github.com/infinispan/infinispan/blob/master/query/src/main/java/org/infinispan/query/backend/IndexModificationStrategy.java#L50</a></div><div>[2] <a href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/context/SingleKeyNonTxInvocationContext.java#L39">https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/context/SingleKeyNonTxInvocationContext.java#L39</a></div><div><br></div></div>