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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11648
   
   ### Brief Description
   
   #### Problem
   Both overloads of `TieredMessageStore#queryMessageAsync` passed `isForce ? 
end : earliestTimeInNextStore` as the upper timestamp bound to 
`fetcher.queryMessageAsync(...)`. When `tieredStorageLevel != 
TieredStorageLevel.FORCE` and a caller requested a bounded window ending before 
the next store's earliest message timestamp (`end < earliestTimeInNextStore`), 
`fetcher.queryMessageAsync(...)` queried `IndexStoreService` / `IndexStoreFile` 
with `endTime = earliestTimeInNextStore` instead of `end`, allowing 
tiered-store messages stored in `(end, earliestTimeInNextStore]` to match and 
be returned past the requested `end`.
   
   #### Fix & Compatibility
   - Extracted a shared private `queryMessageAsync(String topic, String key, 
int maxNum, long begin, long end, Supplier<QueryMessageResult> 
nextQuerySupplier, String indexType)` helper in `TieredMessageStore.java` used 
by both public `queryMessageAsync` overloads (`(topic, key, maxNum, begin, 
end)` and `(topic, key, maxNum, begin, end, indexType, lastKey)`).
   - Computed `queryEnd = isForce ? end : Math.min(end, 
earliestTimeInNextStore)` and passed `queryEnd` to 
`fetcher.queryMessageAsync(...)`.
     - When `tieredStorageLevel == FORCE`, `queryEnd` stays `end` (unchanged).
     - When `tieredStorageLevel != FORCE` and `end >= earliestTimeInNextStore`, 
`queryEnd` stays `earliestTimeInNextStore` (unchanged).
     - When `tieredStorageLevel != FORCE` and `end < earliestTimeInNextStore`, 
`queryEnd` is clamped to `end`.
   - No API, configuration, storage format, or log format changes; compatible 
with existing callers such as `QueryMessageProcessor`.
   - Added regression unit tests in 
`TieredMessageStoreTest#testQueryMessageClampsEndTimeToRequestedBound` covering 
both `queryMessage` overloads for `end < earliestTimeInNextStore`, `begin < 
earliestTimeInNextStore < end`, and `TieredStorageLevel.FORCE`.
   
   ### How Did You Test This Change?
   
   - Pre-fix reproduction (`mvn -B -ntp -o -gs <settings> -pl tieredstore -am 
"-Dspotbugs.skip=true" "-Dtest=TieredMessageStoreTest" test`):
     - `TieredMessageStoreTest#testQueryMessageClampsEndTimeToRequestedBound` 
failed as expected (`Wanted fetcher.queryMessageAsync("MessageStoreTest", 
"key", 32, 0L, 50L)`, actual invocation passed `100L` from 
`TieredMessageStore.java:448`).
   - Post-fix verification (Windows, JDK 21, `mvn -B -ntp -o` with full 
`enforcer`, `checkstyle`, and `spotbugs` enabled across `-pl tieredstore -am`):
     - Query, index, and store tests (`TieredMessageStoreTest` 11/11, 
`IndexStoreFileTest` 24/24, `IndexStoreServiceTest` 10/10, `IndexItemTest` 3/3, 
`MessageStoreFetcherImplCacheTest` 9/9, `MessageStoreTopicFilterTest` 1/1, 
`TieredStoreExceptionTest` 2/2, `DefaultMetadataStoreTest` 6/6, 
`TieredStoreMetricsManagerTest` 5/5, `MessageFormatUtilTest` 6/6, 
`MessageStoreUtilTest` 6/6): `Tests run: 83, Failures: 0, Errors: 0, Skipped: 
0`, Checkstyle `0` violations, SpotBugs `0` bugs, `BUILD SUCCESS`.
     - Remaining `tieredstore` package tests and fetcher query test 
(`FileSegmentTypeTest` 2/2, `GetMessageResultExtTest` 1/1, 
`GroupCommitContextTest` 1/1, `SelectBufferResultTest` 1/1, 
`MessageStoreFetcherImplTest#testQueryMessageAsync` 1/1, `FlatAppendFileTest` 
7/7, `FlatCommitLogFileTest` 3/3, `FlatFileFactoryTest` 1/1, 
`FlatFileStoreTest` 1/1, `FlatMessageFileTest` 4/4, `FileSegmentFactoryTest` 
1/1, `FileSegmentTest` 10/10, `MemoryFileSegmentTest` 1/1, 
`FileSegmentInputStreamTest` 6/6): `Tests run: 40, Failures: 0, Errors: 0, 
Skipped: 0`, Checkstyle `0` violations, SpotBugs `0` bugs, `BUILD SUCCESS`.
     - `git diff --check`: passed (exit 0).
   - Limitations & unverified scope:
     - In full unfiltered `tieredstore` runs on Windows, unrelated 
`Awaitility`/file-lock timing errors were observed in 
`MessageStoreFetcherImplTest#getMessageFromCacheTagFilterTest` 
(`ConditionTimeoutException` inside 
`MessageStoreDispatcherImplTest#dispatchFromCommitLogTest` + Windows 
`FileSystemException` cleanup lock) and intermittently in 
`MessageStoreDispatcherImplTest#dispatchFromCommitLogTest` (which passed 6/6 in 
an earlier post-fix run). Neither calls `TieredMessageStore#queryMessageAsync`, 
and the other methods of `MessageStoreFetcherImplTest` were not re-run 
individually.
     - Tests in upstream/downstream modules (`common`, `remoting`, `store`, 
`broker`, etc.), integration tests (`*IT`), and live cluster deployments were 
not run locally.
   


-- 
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