Skip to content

[ISSUE #10462] Fix concurrency bugs in tiered storage#10471

Open
lizhimins wants to merge 1 commit into
apache:developfrom
lizhimins:feature/10462-concurrency
Open

[ISSUE #10462] Fix concurrency bugs in tiered storage#10471
lizhimins wants to merge 1 commit into
apache:developfrom
lizhimins:feature/10462-concurrency

Conversation

@lizhimins

Copy link
Copy Markdown
Member

What is the purpose of the change

Part of #10462

Fix concurrency bugs including FileChannel race condition, hash overflow, off-by-one, and TOCTOU issues.

Brief changelog

  • PosixFileSegment: use read(ByteBuffer, long) for atomic reads
  • IndexStoreFile: hash & 0x7FFFFFFF to prevent MIN_VALUE overflow
  • IndexStoreFile: held flag fixes unmatched mappedFile.release()
  • IndexStoreFile: >= maxCount fixes off-by-one in query results
  • IndexStoreFile: timeDiff clamped to [0, Integer.MAX_VALUE]
  • IndexStoreFile: slotBuffer moved outside loop with position reset
  • FlatCommitLogFile: local variable snapshot for firstOffset TOCTOU
  • FlatMessageFile: add volatile to topicMetadata/queueMetadata
  • CommitLogInputStream: fix buffer assignment order

Verifying this change

  • mvn compile succeeds
  • mvn test -pl tieredstore passes (112 tests, 0 failures)

🤖 Generated with Claude Code

- PosixFileSegment: use read(ByteBuffer, long) for atomic reads
- IndexStoreFile: hash & 0x7FFFFFFF to prevent MIN_VALUE overflow
- IndexStoreFile: held flag fixes unmatched mappedFile.release()
- IndexStoreFile: >= maxCount fixes off-by-one in query results
- IndexStoreFile: timeDiff clamped to [0, Integer.MAX_VALUE]
- IndexStoreFile: slotBuffer moved outside loop with position reset
- FlatCommitLogFile: local variable snapshot for firstOffset TOCTOU
- FlatMessageFile: add volatile to topicMetadata/queueMetadata
- CommitLogInputStream: fix buffer assignment order

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 47.96%. Comparing base (a6fb9e2) to head (c06042b).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
...che/rocketmq/tieredstore/index/IndexStoreFile.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10471      +/-   ##
=============================================
- Coverage      48.03%   47.96%   -0.08%     
+ Complexity     13286    13280       -6     
=============================================
  Files           1376     1377       +1     
  Lines         100558   100635      +77     
  Branches       12985    12996      +11     
=============================================
- Hits           48305    48265      -40     
- Misses         46333    46421      +88     
- Partials        5920     5949      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oss-sentinel-ai oss-sentinel-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.

Review: Approved ✅

PR: #10471 — Fix concurrency bugs in tiered storage
Type: Bug fix (5 files, +23/-14)

Assessment

Fixes critical concurrency issues in tiered storage:

  • FileChannel race condition (atomic reads)
  • Hash overflow (MIN_VALUE handling)
  • Off-by-one error in query results
  • TOCTOU issues with firstOffset

Verdict

✅ Important concurrency fixes that prevent data corruption. Part of #10462.


🤖 Automated review by oss-sentinel-ai

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