[PR #6752] [MERGED] [client, relay] Increase early-message buffer cap to 10000 to avoid dropping relayed handshakes #28902

Open
opened 2026-08-05 08:07:07 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6752
Author: @riccardomanfrin
Created: 7/13/2026
Status: Merged
Merged: 7/13/2026
Merged by: @riccardomanfrin

Base: mainHead: increase_relay_buffer_msg_queue


📝 Commits (1)

  • 544fe13 Increase relay early msg buffer size to prevent dropping relayed peers' handshakes

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 shared/relay/client/early_msg_buffer.go (+1 -1)

📄 Description

Describe your changes

Bump earlyMsgCapacity from 1000 to 10000 in
shared/relay/client/early_msg_buffer.go.

On a relay reconnect the server replays each peer's first WireGuard
handshake before the local side has finished calling OpenConn, so those
transport messages land in the early-message buffer. The buffer holds one
entry per peer and put() rejects new peers once it hits the cap. Increasing to 10K allows for serving up to 10K different peers handshakes before to push back and require future reattempts.

No public GitHub issue. Fixes a hardcoded buffer cap that drops relayed
handshakes at scale, found during the client-reliability benchmark. Code:
8f64173574/shared/relay/client/early_msg_buffer.go (L13)

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)

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

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal relay client buffer constant. No public API, config, or CLI
change; observable behavior is unchanged except that more peers' early
handshakes survive a reconnect at scale.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

N/A

Summary by CodeRabbit

  • Improvements
    • Increased the number of early messages that can be buffered, helping preserve more incoming messages during initial connection handling.

🔄 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/6752 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 7/13/2026 **Status:** ✅ Merged **Merged:** 7/13/2026 **Merged by:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Base:** `main` ← **Head:** `increase_relay_buffer_msg_queue` --- ### 📝 Commits (1) - [`544fe13`](https://github.com/netbirdio/netbird/commit/544fe1328085b4a281463ff63880b03ea182e448) Increase relay early msg buffer size to prevent dropping relayed peers' handshakes ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `shared/relay/client/early_msg_buffer.go` (+1 -1) </details> ### 📄 Description ## Describe your changes Bump `earlyMsgCapacity` from 1000 to 10000 in [`shared/relay/client/early_msg_buffer.go`](https://github.com/netbirdio/netbird/blob/8f64173574eebc51198ec1c805095b01c3259dba/shared/relay/client/early_msg_buffer.go#L13). On a relay reconnect the server replays each peer's first WireGuard handshake before the local side has finished calling `OpenConn`, so those transport messages land in the early-message buffer. The buffer holds one entry per peer and `put()` rejects new peers once it hits the cap. Increasing to 10K allows for serving up to 10K different peers handshakes before to push back and require future reattempts. ## Issue ticket number and link No public GitHub issue. Fixes a hardcoded buffer cap that drops relayed handshakes at scale, found during the client-reliability benchmark. Code: https://github.com/netbirdio/netbird/blob/8f64173574eebc51198ec1c805095b01c3259dba/shared/relay/client/early_msg_buffer.go#L13 ## 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) > 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). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal relay client buffer constant. No public API, config, or CLI change; observable behavior is unchanged except that more peers' early handshakes survive a reconnect at scale. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Increased the number of early messages that can be buffered, helping preserve more incoming messages during initial connection handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <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 08:07:07 -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#28902