lizhimins opened a new pull request, #10463:
URL: https://github.com/apache/rocketmq/pull/10463

   ## What is the purpose of the change
   
   Closes #10462
   
   对 tieredstore 模块进行系统性优化,涵盖内存背压、并发安全、资源泄漏、线程池、错误处理和日志规范化。
   
   ## Brief changelog
   
   **内存背压**
   - 添加 `tieredStoreDispatchMinFreeMemoryRatio`(默认 0.1)和 
`tieredStoreDispatchMinFreeMemoryMaxBytes`(默认 1GB)
   - dispatch 前通过 `isMemoryEnough()` 检查可用堆内存
   
   **并发修复**
   - PosixFileSegment: `read(ByteBuffer, long)` 替代 `position() + read()`
   - IndexStoreFile: 哈希 `& 0x7FFFFFFF` 防 MIN_VALUE 溢出;`held` flag 修复 
`mappedFile.release()` 未匹配;`>= maxCount` 修复 off-by-one
   - FlatCommitLogFile: firstOffset 本地变量快照防 TOCTOU
   - FlatMessageFile: `topicMetadata`/`queueMetadata` 加 `volatile`
   
   **资源管理**
   - FileSegment `close()` 等待 in-flight commit(30s 超时)
   - PosixFileSegment 存储 RAF 引用防止句柄泄漏
   - MessageStoreExecutor `shutdown()` 添加 `awaitTermination(30s)`
   - 删除 MessageStoreExecutor 单例模式和 `fileRecyclingExecutor`
   - FlatFileFactory 删除泄漏线程池的测试构造函数
   - FlatMessageFile 删除死代码 `inFlightRequestMap`
   
   **线程池优化**
   - commit/fetch 线程池: core `max(4, processors)`, max `max(16, processors * 2)`
   
   **错误处理**
   - TieredMessageStore: 解包 `CompletionException`,`Error` 不吞直接抛出
   - PosixFileSegment: IOException 抛 `RuntimeException` 而非静默返回空 buffer
   - FlatAppendFile: `getFileCorrectSize` 改为有限重试 3 次
   - IndexStoreFile: `timeDiff` clamp 到 `[0, Integer.MAX_VALUE]`
   - `commitAsync` 改为 `tryAcquire()` 替代 `drainPermits()`
   
   **日志规范化**
   - 统一为 `ClassName#methodName, 描述, key={}` 格式
   - 修复 IndexStoreFile 中错误使用 `IndexStoreService` 类名
   - 修复 SLF4J 占位符数量不匹配、参数缺少逗号等问题
   
   ## Verifying this change
   
   - [x] Make sure there is no an existing issue for this
   - [x] Make sure that this PR is sent to `develop` branch
   - [x] Documentation is not needed
   - [x] `mvn compile` succeeds
   - [x] `mvn test -pl tieredstore` passes (112 tests, 0 failures)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to