Skip to content

write-tee: fix preferred backend selection#14427

Open
pracucci wants to merge 3 commits intowrite-teefrom
write-tee-preferred-backend
Open

write-tee: fix preferred backend selection#14427
pracucci wants to merge 3 commits intowrite-teefrom
write-tee-preferred-backend

Conversation

@pracucci
Copy link
Collaborator

What this PR does

In the test cluster we're using, we're currently configuring the mirrored backend == amplified backend == preferred backend. This means that both the mirrored and amplified backend are both marked as preferred, which means that when amplifying the traffic, the amplification is skipped because we have a check to ensure we never amplify to the preferred backend (because that's the sync one).

In this PR I'm changing the preferred backend logic. After rolling out this change, the traffic doubled in our test cluster (we configure it with amplification factor == 1):
Screenshot 2026-02-19 at 16 37 46

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci added the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Feb 19, 2026
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci marked this pull request as ready for review February 19, 2026 16:45
@pracucci pracucci requested a review from a team as a code owner February 19, 2026 16:45
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

@cursor
Copy link

cursor bot commented Feb 19, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Unused idx parameter in parseBackendEndpoint after refactor
    • Removed the unused idx parameter from parseBackendEndpoint and cleaned up the misleading baseIdx variable and its comment at both call sites.

Create PR

Or push these changes by commenting:

@cursor push b042879f33
Preview (b042879f33)
diff --git a/tools/writetee/proxy.go b/tools/writetee/proxy.go
--- a/tools/writetee/proxy.go
+++ b/tools/writetee/proxy.go
@@ -141,8 +141,8 @@
 	// Parse mirrored backend endpoints (comma separated).
 	if cfg.BackendMirroredEndpoints != "" {
 		parts := strings.Split(cfg.BackendMirroredEndpoints, ",")
-		for idx, part := range parts {
-			backend, err := p.parseBackendEndpoint(part, idx, BackendTypeMirrored)
+		for _, part := range parts {
+			backend, err := p.parseBackendEndpoint(part, BackendTypeMirrored)
 			if err != nil {
 				return nil, err
 			}
@@ -155,9 +155,8 @@
 	// Parse amplified backend endpoints (comma separated).
 	if cfg.BackendAmplifiedEndpoints != "" {
 		parts := strings.Split(cfg.BackendAmplifiedEndpoints, ",")
-		baseIdx := len(p.backends) // offset for numeric preferred backend matching
-		for idx, part := range parts {
-			backend, err := p.parseBackendEndpoint(part, baseIdx+idx, BackendTypeAmplified)
+		for _, part := range parts {
+			backend, err := p.parseBackendEndpoint(part, BackendTypeAmplified)
 			if err != nil {
 				return nil, err
 			}
@@ -213,7 +212,7 @@
 	return p, nil
 }
 
-func (p *Proxy) parseBackendEndpoint(endpoint string, idx int, backendType BackendType) (ProxyBackend, error) {
+func (p *Proxy) parseBackendEndpoint(endpoint string, backendType BackendType) (ProxyBackend, error) {
 	// Skip empty ones.
 	endpoint = strings.TrimSpace(endpoint)
 	if endpoint == "" {

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-not-needed PRs that don't need a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments