Skip to content

IGNITE-29227 Fix lost continuous query events with an unregistered transformer result class on an ATOMIC cache - #13769

Merged
zstan merged 7 commits into
apache:masterfrom
rezataroosheh:IGNITE-29227
Nov 6, 2026
Merged

zstan merged 7 commits into
apache:masterfrom
rezataroosheh:IGNITE-29227

Conversation

@rezataroosheh

@rezataroosheh rezataroosheh commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

JIRA: https://issues.apache.org/jira/browse/IGNITE-29227

What

A ContinuousQueryWithTransformer on an ATOMIC cache now delivers the events of a partition whose primary is another node when the class of the transformer result is not yet registered on that node. Before this fix, the listener got none of these events, and later events of the same partition were held as well.

Why

On the primary node, an ATOMIC update notifies the continuous query while it holds the topology read lock. For a listener on another node, CacheContinuousQueryHandler#transformToEntry converts the transformer result to a cache object. Registering a new class is not allowed under the topology lock, so the conversion throws UnregisteredClassException part-way through the notification. GridDhtAtomicCache then registers the class and retries the update with the next update counter. The event for the first counter is never sent, so CacheContinuousQueryPartitionRecovery on the listener node holds the partition's later events, waiting for it. It was reported on the dev list.

The fix keeps the existing path and uses the async callback pool only when the class is not registered:

  • The transformer still runs in the update thread, as before, and only once per event. So a transformer error, for example, a P2P class-loading problem, still fails the update (P2PClassLoadingFailureHandlingTest).
  • The result is also converted in the update thread. If that throws UnregisteredClassException or UnregisteredBinaryTypeException, the conversion and sending (the new notifyRemoteListener) are retried in the async callback pool, striped by partition. This runs outside the topology lock, so the class can be registered there.
  • Events of a partition can take different paths, but CacheContinuousQueryEventBuffer and CacheContinuousQueryPartitionRecovery order them by update counter.

For a listener on another node, a runtime error while converting or sending is now logged instead of reaching the update thread. Listeners on the primary node keep their current behavior.

Workaround for current versions: a remote filter annotated with @IgniteAsyncCallback that accepts all events. With it, the test below passes without the fix.

Related: IGNITE-29226 (same reporter, remote transformed events on a keep-binary cache), PR #13770.

Tests

CacheContinuousWithTransformerUnregisteredClassTest#testUnregisteredResultClassOnAtomicCache, with two server nodes and an ATOMIC cache with one backup. The query runs on the first node, and a key whose primary is the second node is put 3 times with the values 1, 2, and 3. The transformer returns Person, a class that is not registered yet, built from the value. The test checks that all 3 events arrive as Person, in order. It fails without the fix (Received: []).

P2PClassLoadingFailureHandlingTest passes unchanged.

The Contribution Checklist

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see tab PR Check at TC.Bot - Instance 1 or TC.Bot - Instance 2)

Notes

If you need any help, please email dev@ignite.apache.org or ask any advice on https://the-asf.slack.com #ignite channel.

@rezataroosheh rezataroosheh changed the title IGNITE-29227 ContinuousQueryWithTransformer on an ATOMIC cache holds a partition's events if the transformer's result class is not registered IGNITE-29227 Fix lost continuous query events with an unregistered transformer result class on an ATOMIC cache Nov 1, 2026
@rezataroosheh
rezataroosheh marked this pull request as ready for review November 1, 2026 11:46
@zstan
zstan requested a lite review from Copilot November 5, 2026 07:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

5 open issues
What changed in this PR

Fixes an issue where ContinuousQueryWithTransformer on an ATOMIC cache could lose/hold remote transformed events when the transformer result class is unregistered on the primary node.

Changes:

  • Add a regression test covering unregistered transformer result classes on ATOMIC caches.
  • Refactor remote listener notification to convert transformer results and send notifications asynchronously (striped by partition) for ATOMIC caches.
  • Register the new test in IgniteCacheQuerySelfTestSuite6.
File Description
modules/​indexing/​src/​test/​java/​org/​apache/​ignite/​testsuites/​IgniteCacheQuerySelfTestSuite6.java Adds the new regression test to the indexing query test suite.
modules/​core/​src/​test/​java/​org/​apache/​ignite/​internal/​processors/​cache/​query/​continuous/​CacheContinuousWithTransformerUnregisteredClassTest.java Introduces a regression test that reproduces and validates the fix for lost remote transformed events.
modules/​core/​src/​main/​java/​org/​apache/​ignite/​internal/​processors/​cache/​query/​continuous/​CacheContinuousQueryHandler.java Splits remote notification to run cache-object conversion + send in the async callback pool for ATOMIC caches.

Review effort: Lite

@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
@rezataroosheh

Copy link
Copy Markdown
Contributor Author

@zstan, I applied Copilot's test suggestions in f60faa8 and also added the missing super.afterTestsStopped(). I didn't check the event order, because all three events have the same key, so their PersonId values are identical. I answered the evt comment in its thread. The fix itself didn't change.

log.debug("Failed to send event notification to node, node left cluster " +
"[node=" + nodeId + ", err=" + ex + ']');
}
catch (IgniteCheckedException ex) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime error currently will be silently ignored, can you catch Exception here ?

* @param trans Transformer.
* @param transVal Transformer result.
* @param evt Event to transform.
* @return Entry contains only transformed data if transformer exists. Unchanged event if transformer is not set.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return Entry contains only transformed data if transformer exists. Unchanged event if transformer is not set.
* @return Entry contains only transformed data if transformer exists.

// calls this listener under the topology lock, where registration is not allowed, so the conversion and
// sending are done in the async callback pool, ordered by partition.
if (trans != null && cctx.atomic() && !asyncCb) {
ctx.pools().asyncCallbackPool().execute(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you can use a pool only if exception is raized : 99.99% are going into old path also cctx.atomic() && !asyncCb will become redundant:

smth like:

try {
entry = transformToEntry(transVal, evt);
}
catch (UnregisteredClassException | UnregisteredBinaryTypeException ex) {
ctx.pools().asyncCallbackPool().execute(() ->
notifyRemoteListener(cctx, evt, transVal), evt.partitionId());
}

try {
entry = transformToEntry(transVal, evt);
}
catch (UnregisteredClassException | UnregisteredBinaryTypeException ex) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great !

@zstan

zstan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@rezataroosheh thanks ! Seems we need additional tcbot viza and I will merge it.

@rezataroosheh

Copy link
Copy Markdown
Contributor Author

@zstan, thanks for the review and the suggestions! I've started the pipeline to get the TC Bot visa, and I'll add it to the ticket when it's done.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Possible compatibility issues. Please, check rolling upgrade cases

This PR modifies protected classes (with Order annotation).
Changes to these classes can break rolling upgrade compatibility.

Affected files:

  • modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java

@zstan
zstan merged commit 31430b7 into apache:master Nov 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants