Skip to content

IGNITE-28413 Java client: fix race condition in message decoder#7926

Merged
ptupitsyn merged 26 commits into
apache:mainfrom
ptupitsyn:ignite-28413
Apr 7, 2026
Merged

IGNITE-28413 Java client: fix race condition in message decoder#7926
ptupitsyn merged 26 commits into
apache:mainfrom
ptupitsyn:ignite-28413

Conversation

@ptupitsyn
Copy link
Copy Markdown
Contributor

Disable automatic discardReadBytes in Netty to fix a race condition and data corruption caused by concurrent buffer modification:

  • Netty calls discardSomeReadBytes on IO thread, which changes readerIndex
  • TcpClientChannel.asyncContinuationExecutor decodes the response on another thread, which also uses and changes readerIndex

https://issues.apache.org/jira/browse/IGNITE-28413

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a Java thin client race condition in Netty message decoding where the same ByteBuf (and its indices/content) can be modified concurrently by Netty’s internal discard logic and by response decoding on another thread, leading to data corruption.

Changes:

  • Make ClientMessageDecoder final.
  • Disable (or attempt to effectively disable) Netty’s automatic discardReadBytes / discardSomeReadBytes behavior via setDiscardAfterReads(Integer.MAX_VALUE).
  • Annotate the decode(...) override as @Nullable and remove the related suppression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ptupitsyn ptupitsyn merged commit c819020 into apache:main Apr 7, 2026
9 checks passed
@ptupitsyn ptupitsyn deleted the ignite-28413 branch April 7, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants