Skip to content

[ISSUE #11498] Skip timer log scan in checkAndReviseMetrics when no eligible timer slot exists - #11499

Open
Ajax-1 wants to merge 1 commit into
apache:developfrom
Ajax-1:fix/issue-11498-timer-metrics-sentinel
Open

Ajax-1 wants to merge 1 commit into
apache:developfrom
Ajax-1:fix/issue-11498-timer-metrics-sentinel

Conversation

@Ajax-1

@Ajax-1 Ajax-1 commented Oct 28, 2026 •

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Brief Description

TimerWheel.checkPhyPos(readTimeMs, 0) returns Long.MAX_VALUE when no eligible slot exists in the timer wheel. TimerMessageStore.checkAndReviseMetrics() passed that sentinel straight to timerLog.getWholeBuffer(...), so MappedFileQueue.findMappedFileByOffset logged a misleading Offset not matched. Request offset: 9223372036854775807 ... warning whenever a TimerLog mapped file existed.

This PR makes the scan loop skip the sentinel (while (currOffsetPy != Long.MAX_VALUE)) instead of returning early, so the subsequent metrics revision still runs and small-topic counts are still reconciled (e.g. revised to 0 when the wheel is empty). Behavior for valid offsets is unchanged.

How Did You Test This Change?

Added two tests in TimerMessageStoreTest:

  • testCheckAndReviseMetricsWithEmptyTimerWheel: TimerLog has an allocated mapped file and the wheel has no eligible slot; verifies getWholeBuffer(Long.MAX_VALUE) is never called and a stale metric (5) is revised to 0. This test fails without the fix.
  • testCheckAndReviseMetricsWithValidSlot: enqueues two timer records into a valid slot; verifies the scan still works and a stale metric (5) is revised to 2.

Ran mvn -pl store test -Dtest='TimerMessageStoreTest,TimerWheelTest,TimerMetricsTest' locally: all passed (one pre-existing test is skipped on macOS by Assume), checkstyle passed.

…n no eligible timer slot exists

TimerWheel.checkPhyPos returns Long.MAX_VALUE when no slot matches, which was
passed directly to TimerLog.getWholeBuffer and produced a misleading
"Offset not matched" warning. Skip the scan for the sentinel while keeping the
metrics revision.
@Ajax-1
Ajax-1 force-pushed the fix/issue-11498-timer-metrics-sentinel branch from 27923b3 to fe2896a Compare October 28, 2026 16:15
@Ajax-1

Ajax-1 commented Oct 29, 2026

Copy link
Copy Markdown
Author

Hi, a note for reviewers: #11498 was closed by the reporter, but as far as I can tell the issue is still present on develop — checkAndReviseMetrics() still passes the Long.MAX_VALUE sentinel from TimerWheel.checkPhyPos into the TimerLog lookup. This PR fixes it and adds unit tests for the empty-wheel and valid-slot cases. @StiffCoconut, if it was closed by mistake, would you mind reopening it? Otherwise I'm happy to adjust this PR however the committers prefer. Thanks!

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.

[Bug] Timer metrics check logs Offset not matched for Long.MAX_VALUE when no eligible timer slot exists

1 participant