Repository navigation
IGNITE-29291 Fix wrong near cache values after an ATOMIC invokeAll with a write-through store leaves a key unchanged - #13829
Open
rezataroosheh wants to merge 4 commits into
Open
rezataroosheh wants to merge 4 commits into
rezataroosheh wants to merge 4 commits into
Conversation
… an ATOMIC invokeAll with a write-through store leaves a key unchanged
…te-through store when some keys are left unchanged
rezataroosheh
force-pushed
the
IGNITE-29291
branch
from
November 22, 2026 19:07
fd458cd to
26b4ecd
Compare
…utAll and removeAll, and for an unchanged key after put and remove batches
… NearCacheUpdates
Possible compatibility issues. Please, check rolling upgrade casesThis PR modifies protected classes (with Order annotation). Affected files:
|
rezataroosheh
marked this pull request as ready for review
November 23, 2026 22:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA: https://issues.apache.org/jira/browse/IGNITE-29291
What
On an
ATOMICcache with a write-through store, a request with several keys from a client with a near cache now leaves the client's near cache in line with the primary node when some keys of the request are not written. Before this fix, such a key shifted the request index of the keys after it, so the client could:AssertionErrorinGridNearAtomicCache.processNearAtomicUpdateResponse()(assert req.operation() != TRANSFORM), and call the failure handler withCRITICAL_ERROR.A key is not written when the entry processor leaves it unchanged (read-only invoke), when its new value fails validation, or when the interceptor cancels its put or remove. This applies to
invokeAll,putAll, andremoveAll.Why
For such a request, the primary node uses
GridDhtAtomicCache.updateWithBatch(). It collects the entries to write in batches, and passes only the request index of the first entry of a batch toupdatePartialBatch(), which usesfirstEntryIdx + ifor the i-th entry. That is right only if no key between them was left out. This index is used for the near values, TTLs, and skipped indexes sent back to the client, and fordhtUpdRes.processedEntriesCount().Also, a key left out by a read-only invoke or by the interceptor was not sent to the client as skipped. So the client used the value from the request for such a key, or, for
invokeAll, had no value for it at all.Fix
updateWithBatch()keeps the request index of each entry of a batch and passes these indexes toupdatePartialBatch().NearCacheUpdates.addNearTtl()stores the TTL and the expire time at the index of the key instead of appending them. Skipped keys are now added while the request is processed, before the earlier keys in the batch are written, so TTLs are no longer added in key order.GridLongList.set()is added for this.Known limits
UnregisteredClassExceptionorUnregisteredBinaryTypeException, the primary node processes the request again fromdhtUpdRes.processedEntriesCount(). A key after this index that was sent as skipped in the first pass is processed again. If the entry processor returns a different result the second time, the key can be both skipped and written, and the client keeps its old value. If an entry processor returns the same result, the key is skipped twice, which is harmless.invokeAllcan lose the results of keys written before such a retry. This was already the case on master, where the retry could start at a wrong, earlier key and run the entry processor again for keys already written. With this fix, the retry starts after the last written key, so these keys aren't processed again and their results are missing. This can be fixed in a separate ticket.Related: IGNITE-29241 skips a value whose bytes can't be made in the same way as a value that fails validation, so it relies on this fix.
Tests
AtomicNearCacheInvokeAllWithStoreTest, added toIgniteCacheTestSuite10. Each test starts a server and a client with a near cache, puts-1to every key from the client, runs one request from the client, and checks the client's near cache:testUnchangedKeyInTheMiddleOfInvokeAll:invokeAllon keys 1, 2, and 3 leaves key 2 unchanged. On master, the near cache has 3 for key 2, and the client fails with theAssertionErrorabove.testUnchangedKeyInTheMiddleOfInvokeAllWithExpiryPolicy: the same, with an expiry policy, so the response also has a TTL for each key.testInterceptorCancelsKeyInTheMiddleOfInvokeAllandtestInterceptorCancelsKeyInTheMiddleOfInvokeAllRemove: the entry processor sets or removes every key, and the interceptor cancels key 2.testInterceptorCancelsKeyInTheMiddleOfPutAllandtestInterceptorCancelsKeyInTheMiddleOfRemoveAll: the interceptor cancels key 2 of aputAllor aremoveAll.testUnchangedKeyAfterPutAndRemoveBatchesOfInvokeAll:invokeAllon keys 1 to 5 sets key 1, removes key 2, sets key 3, leaves key 4 unchanged, and sets key 5, so the keys are written in three batches.Each new skip and each reset of the batch indexes is covered: removing it from the fix makes the matching test fail with an incorrect near-cache value.
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see tabPR Checkat TC.Bot - Instance 1 or TC.Bot - Instance 2)