Skip to content

Conversation

@mkysel
Copy link
Collaborator

@mkysel mkysel commented Jun 30, 2025

First the easy stuff:

  • got rid of the FixedRegistry

Now the hard stuff:

  • removed the ability to cancel a sub. It is extremely difficult to reason about channels being closed by the reader. It is an anti-pattern that can lead to panics.
  • stop rebuilding the sub on every rebuild
  • made the notifier use a buffered channel of 1 which removes the need for concurrent go routines.

@mkysel mkysel requested a review from a team as a code owner June 30, 2025 22:37
@graphite-app
Copy link

graphite-app bot commented Jun 30, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@mkysel mkysel mentioned this pull request Jun 30, 2025
@macroscopeapp
Copy link

macroscopeapp bot commented Jun 30, 2025

Remove CancelSubscription return values from NodeRegistry interface methods to prevent write-to-closed-channel panics

The NodeRegistry interface has been modified to remove CancelSubscription return values from OnNewNodes() and OnChangedNode() methods in pkg/registry/interface.go. The notifier implementation has been replaced with SingleNotificationNotifier that uses buffered channels and synchronous writes in pkg/registry/notifier.go. A new NodeRegistryWatcher component has been introduced in pkg/sync/nodeRegistryWatcher.go to handle node change subscriptions. The syncWorker has been refactored to use the new watcher component in pkg/sync/syncWorker.go. All implementations, mocks, and tests have been updated to match the new interface, and the FixedNodeRegistry implementation has been removed entirely.

📍Where to Start

Start with the modified NodeRegistry interface in pkg/registry/interface.go to understand the core interface changes, then review the new SingleNotificationNotifier implementation in pkg/registry/notifier.go.

Changes since #933 opened

  • Refactored locking mechanism in NodeRegistryWatcher.triggerCancel method [c44adbd]
  • Added documentation to NodeRegistryWatcher type and methods in sync package [e852668]
  • Reformatted NodeRegistration struct initialization in syncWorker.subscribeToNode method [e852668]

Macroscope summarized e852668.

@mkysel mkysel force-pushed the mkysel/close-panic-possiblility branch from 6e2ce33 to 926679e Compare July 1, 2025 15:20
@mkysel mkysel merged commit cb38d4c into main Jul 1, 2025
9 of 10 checks passed
@mkysel mkysel deleted the mkysel/close-panic-possiblility branch July 1, 2025 17:29
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.

4 participants