[PR #4174] [MERGED] [server, relay] Fix/relay race disconnection #22651

Closed
opened 2026-08-05 06:06:13 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4174
Author: @pappz
Created: 7/18/2025
Status: Merged
Merged: 7/21/2025
Merged by: @mlsmaycon

Base: mainHead: fix/relay-race-disconnection


📝 Commits (10+)

  • 9c8889d Code cleaning
  • 9d23178 Remove store dependency from notifier
  • dc9b183 Enforce the notification orders
  • a819718 Fix invalid disconnection notification
  • 8495ec7 Ensure the order of the events in consumer side
  • bb96c63 Typo fix
  • 747a74f Remove redundant return
  • ab42414 Fix race issue in manager_test.go
  • df081af Fix race issue in test codes
  • edd7f95 Fix Relay test in CI

📊 Changes

18 files changed (+234 additions, -117 deletions)

View changed files

📝 .github/workflows/golang-test-linux.yml (+7 -3)
📝 client/internal/peer/worker_relay.go (+2 -2)
📝 relay/client/client.go (+1 -1)
📝 relay/client/client_test.go (+7 -3)
📝 relay/client/dialer/race_dialer.go (+12 -10)
📝 relay/client/dialer/race_dialer_test.go (+7 -7)
📝 relay/client/guard.go (+2 -1)
📝 relay/client/manager.go (+0 -11)
📝 relay/client/manager_test.go (+31 -10)
📝 relay/healthcheck/receiver_test.go (+44 -1)
📝 relay/healthcheck/sender_test.go (+10 -1)
📝 relay/metrics/realy.go (+18 -6)
📝 relay/server/listener/quic/listener.go (+1 -4)
📝 relay/server/peer.go (+13 -1)
📝 relay/server/relay.go (+8 -6)
📝 relay/server/store/listener.go (+43 -41)
📝 relay/server/store/notifier.go (+2 -5)
📝 relay/server/store/store.go (+26 -4)

📄 Description

Describe your changes

Avoid invalid disconnection notifications in case the closed race dials.
In this PR resolve multiple race condition questions. Easier to understand the fix based on commit by commit.

  • Remove store dependency from notifier
  • Enforce the notification orders
  • Fix invalid disconnection notification
  • Ensure the order of the events on the consumer side

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4174 **Author:** [@pappz](https://github.com/pappz) **Created:** 7/18/2025 **Status:** ✅ Merged **Merged:** 7/21/2025 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `fix/relay-race-disconnection` --- ### 📝 Commits (10+) - [`9c8889d`](https://github.com/netbirdio/netbird/commit/9c8889d4a5ff074d60faf3576763d45a7367fe32) Code cleaning - [`9d23178`](https://github.com/netbirdio/netbird/commit/9d2317823885ef0b1f1d181880bb330ec1427c0b) Remove store dependency from notifier - [`dc9b183`](https://github.com/netbirdio/netbird/commit/dc9b1836a870a18865a8d6bc232dc59e5e0a9d26) Enforce the notification orders - [`a819718`](https://github.com/netbirdio/netbird/commit/a819718c13276d92b7fabd6f780fa6b544c5a581) Fix invalid disconnection notification - [`8495ec7`](https://github.com/netbirdio/netbird/commit/8495ec7e5c70f74e57d2957eda169173262af91e) Ensure the order of the events in consumer side - [`bb96c63`](https://github.com/netbirdio/netbird/commit/bb96c630c8ba9e05c8a5f956b71c189c86ad7e24) Typo fix - [`747a74f`](https://github.com/netbirdio/netbird/commit/747a74f36445221bc5ad353ec7546672e5068ca6) Remove redundant return - [`ab42414`](https://github.com/netbirdio/netbird/commit/ab424145326af8d0718b3846b21fe211d692b682) Fix race issue in manager_test.go - [`df081af`](https://github.com/netbirdio/netbird/commit/df081af1982c23b0b9c53d862af61a1290c567b1) Fix race issue in test codes - [`edd7f95`](https://github.com/netbirdio/netbird/commit/edd7f956d9e2bf2d987fa5c3ac9015e274e380ee) Fix Relay test in CI ### 📊 Changes **18 files changed** (+234 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/golang-test-linux.yml` (+7 -3) 📝 `client/internal/peer/worker_relay.go` (+2 -2) 📝 `relay/client/client.go` (+1 -1) 📝 `relay/client/client_test.go` (+7 -3) 📝 `relay/client/dialer/race_dialer.go` (+12 -10) 📝 `relay/client/dialer/race_dialer_test.go` (+7 -7) 📝 `relay/client/guard.go` (+2 -1) 📝 `relay/client/manager.go` (+0 -11) 📝 `relay/client/manager_test.go` (+31 -10) 📝 `relay/healthcheck/receiver_test.go` (+44 -1) 📝 `relay/healthcheck/sender_test.go` (+10 -1) 📝 `relay/metrics/realy.go` (+18 -6) 📝 `relay/server/listener/quic/listener.go` (+1 -4) 📝 `relay/server/peer.go` (+13 -1) 📝 `relay/server/relay.go` (+8 -6) 📝 `relay/server/store/listener.go` (+43 -41) 📝 `relay/server/store/notifier.go` (+2 -5) 📝 `relay/server/store/store.go` (+26 -4) </details> ### 📄 Description ## Describe your changes Avoid invalid disconnection notifications in case the closed race dials. In this PR resolve multiple race condition questions. Easier to understand the fix based on commit by commit. - Remove store dependency from notifier - Enforce the notification orders - Fix invalid disconnection notification - Ensure the order of the events on the consumer side ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 06:06:13 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#22651