Skip to content

fix(store): remove canceled height waiters - #3445

Open
luangucun wants to merge 1 commit into
evstack:mainfrom
luangucun:main
Open

fix(store): remove canceled height waiters#3445
luangucun wants to merge 1 commit into
evstack:mainfrom
luangucun:main

Conversation

@luangucun

@luangucun luangucun commented Sep 2, 2026

Copy link
Copy Markdown

Overview

Closes #3444

heightSub.Wait registers a channel for every requested height, but the context-cancellation path did not unregister it. For heights that are never reached, canceled waiters remained referenced by heightChs, causing stale channels to accumulate during normal P2P sync cancellation and timeout lifecycles.

This change:

  • removes the specific canceled waiter under heightMu;
  • preserves other waiters registered for the same height;
  • handles cancellation racing with notifyUpTo;
  • adds regression tests for cleanup and concurrent cancellation/notification.

Tests:

  • go test ./pkg/store
  • go test -race ./pkg/store -run 'TestHeightSubWaitCancellation' -count=10

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of canceled height waits to prevent stale internal waiters from accumulating.
    • Preserved notifications for other active waiters when one wait is canceled.
    • Improved reliability when cancellation and height updates occur concurrently.
  • Tests

    • Added coverage for canceled waits, multiple waiters, and concurrent cancellation scenarios.

Signed-off-by: luangucun <luangucun@outlook.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 3445c236-3027-48f0-a1c2-50a800396181

📥 Commits

Reviewing files that changed from the base of the PR and between cca63ca and d8aa5fb.

📒 Files selected for processing (2)
  • pkg/store/store_adapter.go
  • pkg/store/store_adapter_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The height subscription now removes canceled waiter channels from its internal map. Tests cover repeated cancellation, independent waiters at the same height, and cancellation concurrent with SetHeight.

Changes

Height waiter cancellation cleanup

Layer / File(s) Summary
Remove canceled height waiters
pkg/store/store_adapter.go
Wait removes a canceled waiter channel from heightChs. Empty height entries are deleted while holding heightMu.
Validate cancellation cleanup
pkg/store/store_adapter_test.go
Tests verify repeated cleanup, preservation of other waiters, notification behavior, and cancellation races with SetHeight. The tests add the required time import.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d8aa5

The change removes canceled internal waiters while preserving normal notification and cancellation behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing canceled height waiters from the store.
Description check ✅ Passed The description includes the required Overview section, explains the problem and solution, links issue #3444, and lists regression tests.
Linked Issues check ✅ Passed The implementation and tests address issue #3444 by removing only canceled waiters, preserving other waiters, handling cancellation races, and adding concurrency coverage.
Out of Scope Changes check ✅ Passed The changes are limited to the height waiter cleanup implementation and directly related regression tests. No unrelated scope is present.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

store: canceled height waiters remain registered until the height is reached

1 participant