Skip to content

test(logservice): make the HAKeeper allocate-retry cancellation test deterministic - #31800

Closed
MatrixAdventurer wants to merge 1 commit into
matrixorigin:mainfrom
MatrixAdventurer:fix/31789-hakeeper-retry-test-deterministic
Closed

MatrixAdventurer wants to merge 1 commit into
matrixorigin:mainfrom
MatrixAdventurer:fix/31789-hakeeper-retry-test-deterministic

Conversation

@MatrixAdventurer

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG (test flake)

Which issue(s) this PR fixes:

Fixes #31789

Summary

TestAllocateBatchIDRetriesPrepareClientErrorUntilContextDone gave the whole call a 55 ms deadline with a 20 ms retry interval and required at least 2 discovery attempts. A scheduler pause after the first attempt (CPU throttling in CI) used up the deadline, so the product correctly returned DeadlineExceeded after 1 attempt and the attempt-count assertion failed.

Test-only change (hakeeper_client_test.go, no production code):

  • retries until canceled: discovery keeps failing with net.ErrClosed; the stub cancels the caller context during the 3rd attempt (1-minute safety timeout). Asserts context.Canceled and exactly 3 attempts, so the retry count comes from the stub, not from wall-clock time.
  • stops at deadline: a 20 ms caller deadline still ends the loop with context.DeadlineExceeded; only attempts >= 1 is asserted.

Product retry and cancellation behavior is unchanged.

Evidence

Same SIGSTOP injection as in the issue (race test binary, GOMAXPROCS=1, pause 100 ms, 5 ms after === RUN):

main test this PR
injected runs failing 9 / 20 ("1" is not greater than or equal to "2", line 1888) 0 / 80
  • go test -race -tags matrixone_test -short -run TestAllocateBatchIDRetries ./pkg/logservice passes; TestAllocate* with -count=50 under GOMAXPROCS=1 passes.

Merge Danger

None for production; one test function rewritten.

本操作由 LW 授权的 Grok Bot 智能体执行。

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 30, 2026
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Oct 30, 2026
@XuPeng-SH XuPeng-SH closed this Oct 30, 2026
@XuPeng-SH

Copy link
Copy Markdown
Contributor

will fixed by @XuPeng-SH

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: HAKeeper allocation retry UT assumes two attempts within a 55ms deadline

3 participants