return invokeNextThenAccept(ctx, command, (rCtx, rCommand, rv) -> processComputeCommand(((ComputeCommand) rCommand), rCtx, stateBeforeCompute, null));
Gustavo
Hi all,I'm really struggling with something in order to finish the compute methods.I added a test in ClusteredCacheWithElasticsearchIndexManagerIT public void testToto() throws Exception {
SearchManager searchManager = Search.getSearchManager(cache2);
QueryBuilder queryBuilder = searchManager
.buildQueryBuilderForClass(Person.class)
.get();
Query allQuery = queryBuilder.all().createQuery();
String key = "newGoat";
Person person4 = new Person(key, "eats something", 42);
cache2.putIfAbsent(key, person4);
StaticTestingErrorHandler.assertAllGood (cache1, cache2);
List<Person> found = searchManager.<Person>getQuery(allQuery, Person.class).list();
assertEquals(1, found.size());
assertTrue(found.contains(person4));
}I put some logs in the processPutKeyValueCommandmethod in the QueryInterceptor to explain what is happening. 2 threadsSometimes two threads get involved.= Thread 72 First (or second) callIt happens from a non local Node. The so the shouldModifyIndexes says "no, you should not modify any index" because the IndexModificationStrategyis set to "LOCAL ONLY". [1] 72 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeB-19565 72 should modify false72 previousValue null72 putValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null} // value in the command72 contextValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null} //value in the invocation context= Thread 48 Second (or first) callthe origin is null, and this is considered as a LOCAL in the SingleKeyNonTxInvocationContext. [2] 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's correctly updated.48 ctx.getOrigin() = null48 should modify true48 previousValue null48 putValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}48 contextValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}And everything is ok. Everything is fine too in the case of a compute method instead of the put method.But sometimes, this is not executed like that.3 threadsWhat 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.But just later, another thread get'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 QueueAsyncInvocationStage.80 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeA-65110 80 should modify false80 prev null80 putValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}80 contextValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}38 ctx.getOrigin() = ClusteredCacheWithElasticsearchIndexManagerIT-NodeB-35919 38 should modify false38 prev null38 putValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}38 contextValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}48 ctx.getOrigin() = null48 should modify true48 prev null48 putValue Person{name='newGoat', blurb='eats something', age=42, dateOfGraduation=null}48 contextValue nullThis execution works perfectly with PutKeyValueCommand. But don't work wth compute.The "computed value" 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.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.ClusteredCacheWithInfinis panDirectoryTest Thank you very much for your help !Katia
_______________________________________________
infinispan-dev mailing list
infinispan-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev