Skip to content

Conversation

@oneby-wang
Copy link
Contributor

Fixes #25145

Motivation

See #25145 (comment).

Due to the use of Netty Recycler, a ConcurrentBitSetRecyclable instance may still be used after being recycled. However, recycling clears all bits, which may cause the isDuplicate() method return true under some race conditions.

If we execute to the point where bitSet != null, but the thread is then switched out and bitSet gets recycled, the isDuplicate() method will return true at that point.

if (messageIdAdv.getBatchIndex() >= 0) {
ConcurrentBitSetRecyclable bitSet = pendingIndividualBatchIndexAcks.get(key);
return bitSet != null && !bitSet.get(messageIdAdv.getBatchIndex());
}

Modifications

Replace ConcurrentBitSetRecyclable with ConcurrentBitSet, ensure that ackSet is only cleared when the ackXxx method is invoked.

As #24766 suggested, we should stop using Netty Recycler in new code. Since using Netty Recycler is kind of error prone way here, I think we should remove it.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: oneby-wang#26

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Java consumer occasionally missing one message of a batched entry

1 participant