[ 
https://issues.apache.org/jira/browse/IGNITE-29291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18151121#comment-18151121
 ] 

Reza Taroosheh commented on IGNITE-29291:
-----------------------------------------

[~NSAmelchev], could you please review this fix? PR: 
https://github.com/apache/ignite/pull/13829

In {{GridDhtAtomicCache.updateWithBatch()}}, a key that is not written 
(read-only invoke, failed validation, interceptor cancel) shifts the request 
index of the keys after it, so a client with a near cache gets wrong values or 
fails with {{CRITICAL_ERROR}}. The fix keeps the request index of each batch 
entry. {{AtomicNearCacheInvokeAllWithStoreTest}} reproduces it on master, and 
the TC visa above is clean.

This fix is a prerequisite for IGNITE-29241 (PR #13779), which skips one more 
kind of key in the same path.


> ATOMIC invokeAll with a write-through store puts wrong values into the near 
> cache when a key is left unchanged
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-29291
>                 URL: https://issues.apache.org/jira/browse/IGNITE-29291
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Reza Taroosheh
>            Assignee: Reza Taroosheh
>            Priority: Major
>             Fix For: 2.20
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> GridDhtAtomicCache.updateWithBatch() collects the entries to write in the 
> list "filtered" and passes
> "firstEntryIdx" to updatePartialBatch(). updatePartialBatch() uses 
> "firstEntryIdx + i" as the request
> index of the i-th entry of the batch. This is right only if the batch has no 
> gaps.
> A key is skipped without being added to the batch when:
> - the entry processor does not modify the entry (read-only invoke);
> - the new value fails validation;
> - the bytes of the new value can't be made, for example because the class 
> registration is interrupted (added by IGNITE-29241, which handles this like a 
> validation failure);
> - the interceptor cancels the update.
> "firstEntryIdx" is advanced only for a key rejected by the filter, and that 
> is right only if no key was
> added to the batch before it. Also, after a retry on 
> UnregisteredClassException or
> UnregisteredBinaryTypeException, the loop starts at 
> dhtUpdRes.processedEntriesCount(), but
> "firstEntryIdx" starts at 0.
> The wrong index is used for res.addNearValue(), res.addNearTtl(), 
> res.addSkippedIndex() and
> dhtUpdRes.processedEntriesCount().
> updateWithBatch() is used for requests with more than one key on a cache with 
> a write-through store
> that is not local.
> Reproducer:
> One server, one client with a near cache, ATOMIC cache with a write-through 
> store. The client puts keys
> 1, 2 and 3, then calls invokeAll on them. The entry processor sets each value 
> to its key, but leaves key 2
> unchanged.
> Expected: the client's near cache has 1, the old value, and 3.
> Actual:
> - the near cache of the client has value 3 for key 2;
> - the client fails with an AssertionError in 
> GridNearAtomicCache.processNearAtomicUpdateResponse()
>   ("assert req.operation() != TRANSFORM"), because index 2 has neither a near 
> value nor a skipped index.
>   The failure handler is called with CRITICAL_ERROR.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to