Repository navigation
Conversation
pyt pods will refuse work that isn't theirs with 421 Misdirected Request. Today rudder-server treats any 4xx as final, so a 421 would fail the whole batch; this must be live before pyt starts sending them. pyt traffic now uses one transformer client per target (pyt-<ws>:8080, test-pod hosts, the AST URL), built on first use from the UserTransformer client config and closed once idle (Processor.UserTransformer.pytClientIdleTimeout, default 5m). Clients are reference counted, so neither the idle close nor a reset ever closes one under a request. JS keeps the shared client. On a 421 from per-workspace PyT, doPost and forwardTest count it (processor_user_transformer_misdirected_requests_total), retire the target's client once per client however many concurrent chunks got the 421 (processor_user_transformer_client_resets_total), and retry. The fresh client resolves the target again, so a workspace at zero fails the lookup and goes through the existing cold-start path; the 421 itself never touches the cold-start counter. A 421 that outlasts doPost's retries returns ErrMisdirected, which maps to 819 like ErrColdStart, so sendBatch keeps retrying instead of panicking. Outside per-workspace PyT a 421 stays a final 4xx. transformerclient gains NewClosableClient, returning the client together with the func that releases it.
- sendBatch's retry error carries the 819 body, so the log tells a misdirected request from a cold start; a 421 is no longer logged a second time by doPost's retry notify. - doPost defers the pyt client's release right after acquiring it; the registry is built before the options run, so WithClient sets its factory directly and Client.newPyTClient is gone. - One error text for a persistent 421 or cold start, the 819 rationale kept once, docs corrected on field immutability, NewClosableClient and forwardTest's deadline, plus why the idle default is 5m. - Tests: the reset through New's real httplb factory, a forward-path 421 followed by a failed lookup, the idle timeout key; the current-pod test can no longer pass without a reset, the httplb close test fails instead of hanging, the stdlib close test checks the dropped connection, and test helpers get test-specific names.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7494 +/- ##
==========================================
+ Coverage 84.54% 84.60% +0.06%
==========================================
Files 632 633 +1
Lines 62839 62923 +84
==========================================
+ Hits 53128 53239 +111
+ Misses 9708 9681 -27
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…421 reason - onMisdirected passes X-Rudder-Error-Reason through retryReasonTag before it reaches the log and the ErrMisdirected error, and from there the 819 body, sendBatch's retry log and failed events. - Tests: a slow close holds up neither the release that starts it nor other targets, from both the retire and the idle path; WithClient's client serves pyt targets and is never closed by the registry; the reason is bounded for an over-long, a per-request and a missing value. The JS 421 test runs with bounded retries, so a regression fails instead of hanging, and the real-client close check no longer calls require inside Eventually. - Comments: an idle timeout <=0 closes a client after every request; forwardTest keeps its retry log for a 421 because a dashboard panel reads it.
…he-pyt-client-on-421
…-on-421' of github.com:rudderlabs/rudder-server into feature/pipe-3553-01-rudder-server-reset-the-pyt-client-on-421
fracasula
marked this pull request as ready for review
October 19, 2026 15:01
…he-pyt-client-on-421
ktgowtham
approved these changes
Oct 22, 2026
itsmihir
approved these changes
Oct 23, 2026
fracasula
deleted the
feature/pipe-3553-01-rudder-server-reset-the-pyt-client-on-421
branch
October 23, 2026 09:10
This was referenced Oct 26, 2026
Closed
Merged
itsmihir
pushed a commit
that referenced
this pull request
Oct 26, 2026
🤖 I have created a release *beep* *boop* --- ## [1.92.0-rc.1](v1.91.0...v1.92.0-rc.1) (2026-10-26) ### Features * **processor:** pyt test-pod deployer sets PYT_MODE=test ([#7506](#7506)) ([a050ed6](a050ed6)) * **processor:** reset the per-workspace pyt client on 421 ([#7494](#7494)) ([83db4d6](83db4d6)) * **router:** re-fetch the cached OAuth token when the control plane holds a newer secret (PRO-5947) ([#7478](#7478)) ([742779d](742779d)) * **router:** tag oauth_action counters with destinationId and count AUTH_STATUS_INACTIVE (PRO-5946) ([#7477](#7477)) ([0e15eb4](0e15eb4)) ### Bug Fixes * flaky TestDrainConfigRoutine failing with "database is closed" ([#7489](#7489)) ([9baa89f](9baa89f)) ### Miscellaneous * block new ginkgo/gomega usage in tests ([#7502](#7502)) ([e1c9d38](e1c9d38)) * bump dependency versions ([#7522](#7522)) ([1067ff4](1067ff4)) * enforce errors.AsType and point CLAUDE.md at AGENTS.md ([#7521](#7521)) ([5c7e088](5c7e088)) * go 1.27.3 ([#7516](#7516)) ([3c240a3](3c240a3)) * migrate debugger, services, async destination and utils tests from ginkgo to testify ([#7503](#7503)) ([1a8c85a](1a8c85a)) * migrate gateway, rsources, reporting, batchrouter and manager tests from ginkgo to testify ([#7507](#7507)) ([ffdd505](ffdd505)) * remove ginkgo and gomega from tests ([#7508](#7508)) ([d3e7e0f](d3e7e0f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir
pushed a commit
that referenced
this pull request
Oct 27, 2026
🤖 I have created a release *beep* *boop* --- ## [1.92.0](v1.91.0...v1.92.0) (2026-10-26) ### Features * **processor:** pyt test-pod deployer sets PYT_MODE=test ([#7506](#7506)) ([a050ed6](a050ed6)) * **processor:** reset the per-workspace pyt client on 421 ([#7494](#7494)) ([83db4d6](83db4d6)) * **router:** re-fetch the cached OAuth token when the control plane holds a newer secret (PRO-5947) ([#7478](#7478)) ([742779d](742779d)) * **router:** tag oauth_action counters with destinationId and count AUTH_STATUS_INACTIVE (PRO-5946) ([#7477](#7477)) ([0e15eb4](0e15eb4)) ### Bug Fixes * flaky TestDrainConfigRoutine failing with "database is closed" ([#7489](#7489)) ([9baa89f](9baa89f)) ### Miscellaneous * block new ginkgo/gomega usage in tests ([#7502](#7502)) ([e1c9d38](e1c9d38)) * bump dependency versions ([#7522](#7522)) ([1067ff4](1067ff4)) * enforce errors.AsType and point CLAUDE.md at AGENTS.md ([#7521](#7521)) ([5c7e088](5c7e088)) * go 1.27.3 ([#7516](#7516)) ([3c240a3](3c240a3)) * migrate debugger, services, async destination and utils tests from ginkgo to testify ([#7503](#7503)) ([1a8c85a](1a8c85a)) * migrate gateway, rsources, reporting, batchrouter and manager tests from ginkgo to testify ([#7507](#7507)) ([ffdd505](ffdd505)) * remove ginkgo and gomega from tests ([#7508](#7508)) ([d3e7e0f](d3e7e0f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pyt pods will soon refuse work that isn't theirs with 421 Misdirected Request (PIPE-3552). This PR makes rudder-server recover from a 421 instead of failing the batch. It has to be live everywhere before pyt starts sending 421.
Why: on 2026-10-08, production
/customTransformtraffic for one workspace reached an ephemeral pyt test pod. That pod had been given the IP the workspace's production pod released about 100s earlier. The workspace was scaled to zero, and httplb keeps its last known addresses when DNS answers empty or fails (balancer.goin v0.4.1), so the stale IP stayed in the client. Today rudder-server treats a 421 like any other 4xx, which is final and fails every event in the batch.What changes:
pyt-<ws>:8080, the ephemeral test-pod hosts and the AST URL, keyed byscheme://host:port.UserTransformerclient config, and closed afterProcessor.UserTransformer.pytClientIdleTimeoutof idleness (reloadable, default 5m).Closewaits for requests already in flight, but fails any that start afterwards.doPost), per-workspace PyT only:processor_user_transformer_misdirected_requests_total{workspaceID, language}and logged withX-Rudder-Error-Reason. pyt chooses that header, so it is capped and sanitised the same way as the retry-reason stats tag before it reaches logs and error texts.processor_user_transformer_client_resets_total{workspaceID, reason="misdirected"}.doPost's retries returnsErrMisdirected, which becomes 819 likeErrColdStart, sosendBatchkeeps retrying instead of panicking.forwardTest, which serves/test,/testRun,/test-libraryand/extract-libs):path, like the cold-start counter there.maxRetryand the caller's deadline.transformerclient.NewClosableClient: new; returns the client together with its close func.NewClientis unchanged for its other callers.sendBatchretry log: now carries the 819 body, so it tells a misdirected request apart from a cold start.Why reset the whole client instead of dropping one address: httplb has no API to evict a single address. A custom health checker would have to map each response back to its connection, and decide when that IP can be trusted again. A fresh client scoped to one target avoids both and is cheap.
Testing:
httptestpods, with a fake resolver so a failed DNS lookup is deterministic.New's real client factory;forwardTest's reset, retry and deadline;WithClient-injected client never being closed.go test -raceforinternal/transformer-client,processor/internal/transformer,processor/internal/transformer/user_transformerandprocessor/cpservice.master:destination_transformer,sourcehydrationandtrackingplan_validationfail under-racebecause of races in their own test fixtures, so they ran without it. This PR doesn't touch them../processorpackage tests.Not in this PR: setting
PYT_MODE=testin the test-pod deployer (PIPE-3554), and DMT's handling of 421 (PIPE-3555).Linear Ticket
Fixes PIPE-3553
Security