Repository navigation
feat(core): capture the final recorded error for failed rETL records - #7295
Conversation
Read from the first event, honored only on authenticated rETL traffic (non-empty source job run id), carried into job params, and deleted from every event's context.sources before the payload is rebuilt so the destination never sees it.
…meters EventParams -> Metadata -> ParametersT, all omitempty so non-rETL and non-opted-in jobs marshal unchanged.
Additive error_response column on rsources_failed_keys_v2_records, envelope unwrap (reason/response/Error/error), rune-safe byte cap (Rsources.failedKeys.maxErrorLength, default 2048, reloadable) then UTF-8 sanitize, gated by captureErrorDetail AND the per-connection capture_error opt-in AND reloadable connection/workspace blacklists. Suppression drops only the message; record and code are untouched. Served additively as the v2 failed-records 'error' leaf. Aggregate capture telemetry per publish; message bodies are never logged.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7295 +/- ##
==========================================
+ Coverage 79.91% 80.28% +0.36%
==========================================
Files 612 615 +3
Lines 68676 69059 +383
==========================================
+ Hits 54884 55445 +561
+ Misses 10564 10358 -206
- Partials 3228 3256 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…etadata rebuild The user-transformation response assembly copies rETL metadata field by field and omitted CaptureError, zeroing the flag between the gateway and the router jobs - capture never fired end-to-end despite a correct stamp and strip. Found by the cross-repo E2E (PRO-5906): with this fix the full chain lands the destination's error text in the customer's rej_* table.
a7c37f3 to
a8e3adc
Compare
The opt-in now rides the X-Rudder-Capture-Error-Detail request header (exact value "true"), seeded into the auth context alongside the job and task run id headers, instead of context.sources.capture_error in the first event's payload. The per-event strip disappears: the payload field is no longer consulted, so a mapped column or constant can no longer forge the opt-in and user payloads pass through unmodified.
…for the rETL capture opt-in
|
Adopted — you were right, and the precedent held up all the way down. As of d92738e the opt-in travels as a Two knock-on simplifications came free:
Spec updated on rudder-specs#109 ( One follow-up your review of this area might have an opinion on: the honor gate still keys on Note: this push deliberately addresses only the carrier rework. The architects-panel review on the spec PR (B1 query-string redaction, M1 first-wins upsert) is being handled separately — B1/M1 fixes follow after the design discussion rather than riding this change. |
…n config, pinned per run Retires the X-Rudder-Capture-Error-Detail request intake and the gateway->processor carrier (EventParams/Metadata CaptureError). The flag is now born at the ParametersT marshal site: resolved from the connection's config.source.syncSettings.errorDetailsConfig.enabled in the processor's backend-config subscription, fail-closed, with the first resolution per job run id pinned (24h TTL, bounded store - job run ids are client-mintable) so every record of one sync carries the same decision and a toggle takes effect from the next sync. Nothing client-supplied feeds the decision; forged headers or payload fields are inert because no code reads them.
|
Update since my last comment here: we went a step further than the header. There's no wire signal at all anymore. The processor resolves errorDetailsConfig.enabled from the connection in its own backend-config subscription at the point it builds ParametersT, and pins the first answer per job run id so a mid-sync toggle can't split a run (24h TTL, bounded map, since run ids are client-mintable). The gateway intake and the EventParams/Metadata plumbing are gone as of e54b728, so a forged header or payload flag is inert, nothing reads them. Spec is updated on rudder-specs#109 (server LLD §3.6). Your original comment is what pushed it here: once the opt-in moved out of the payload, the natural end state was not trusting the client for it at all. |
atzoum
left a comment
There was a problem hiding this comment.
rETL error-capture decision store
Problem
The current opt-in mechanism is wrong:
- The decision lives in memory. A rudder-server restart during a sync loses it.
- Multiple rudder-server nodes take part in one sync. Each node makes its own decision.
- The opt-in bookkeeping leaked into statsCollector (
captureErrorJobIds).
Goal
Build one component. This component is the authority for one question: must a sync run (jobRunID) on a given connection (sourceID and destinationID) capture error responses?
Design
The component has two inputs:
- A pinned decision per jobRunID, stored in a central database table. Every node and every restart sees the same value.
- Operator settings from reloadable config, applied on each call.
See internal/drain-config for a component with a similar shape. Do not copy its code. Use the same idea: a shared or local database, with a maximum of 2 connections.
Interface
The component exposes one method:
GetErrorResponse(ctx context.Context, key statKey, status *jobsdb.JobStatusT) (string, error)The method returns the error text to store, or "" when capture is off for this combination. A database error propagates to the caller.
The method applies its checks in this order:
- If the raw error response is empty,
'', or{}, return"". Do not touch the cache or the database. - If the enabled/disabled flag is off, return
"". Do not touch the cache or the database. Do not insert a row. - Read the pinned decision for the jobRunID. If the decision is false, return
"". - If the connection or the workspace is on a blocklist, return
"". - Extract the error text. Clip it to the max length. Sanitize it. Return it.
Pinned decision
The decision value comes from backend config: source.syncSettings.errorDetailsConfig.enabled. The component subscribes to backend config when it starts. If backend config does not contain the connection, the decision is false.
The decision is stored in one table with 3 columns: job_run_id, store_error_responses, created_at. The key is job_run_id alone. This is sufficient because in rETL one jobRunID maps to one source.
Keep database queries and inserts to a minimum:
- On startup, load all entries from the database into a memory cache.
- On a cache miss for a jobRunID:
- Begin a transaction.
- Take a transaction-scoped advisory lock:
pg_advisory_xact_lock(classid, objid). Use a dedicated class id for this component and a hash of the jobRunID as the object id. The two-argument form has its own keyspace. It cannot collide with the single-argument locks that jobsdb (hash-derived ids) and the rsources handler (id100020001) already use. - Look up the jobRunID in the table.
- If the row is not found, compute the decision from backend config and insert it.
- Commit the transaction and cache the result.
Do not limit the number of jobRunIDs in the memory cache. The memory overhead is not important at this stage.
Operator settings
Move all configuration logic that now lives in statsCollector (errorCaptureSettings) into the new component:
- The enabled/disabled flag (
Rsources.failedKeys.captureErrorDetail), used in step 2. - The blocklists, used in step 4.
- The max-length cap, used in step 5.
Do not overengineer the solution. Do not use sync.Map or settings snapshotting at this stage. Plain reloadable config reads are sufficient.
Cleanup
The component periodically deletes entries older than a configured age. The default is 24 hours. drainConfigManager does something similar, but do not copy its patterns without review.
A run that is longer than the retention age loses its row. A later cache miss computes the decision again, and the value can change mid-run. This is acceptable.
Lifecycle
Create one instance per process, at application startup. Pass it to every NewStatsCollector caller. The component owns its cleanup goroutine. The application starts and stops the component.
Integration
Inject the component into statsCollector. Replace captureErrorResponse with a call to the new method. Remove captureErrorJobIds and errorCaptureSettings from statsCollector.
Change CollectFailedRecords to accept a context.Context and return an error. Errors from GetErrorResponse propagate through it.
Remove the plumbing that the new component makes obsolete:
processor/error_capture_optin.go(captureOptInPins), its wiring in processor, and its tests.gateway/handle_forged_capture_signals_test.go. The gateway header code is already gone. Only this test remains.
Names
Proposed names: table rsources_sync_settings, component SyncSettingDelegate. Both are open to better alternatives.
filterProcessorEnabledDestinations rebuilt ConfigT from an allowlist of four fields, so anything added to the struct after that allowlist was written never reached the topic. Connections was one of them: the processor subscribes to TopicProcessConfig, so connectionConfigMap was rebuilt from an empty Connections map on every config push. resolveCaptureErrorOptIn reads the rETL error-capture opt-in off that map and fails closed, so it answered false for every connection regardless of what the control plane published. capture_error was never stamped on ParametersT, the failed-records collector never kept the destination's error text, and rej_* landed with error_message NULL. No error, no log, no failing test. Reproduced on mini and on dev (profiles-qa, Snowflake): rej_* rows written with correct codes and identifiers, error_message empty for every row. Instrumenting the processor showed connectionConfigMap size=0 against 14 connections in the config the server had just fetched. Destination filtering is this function's only job, so it now starts from the complete config and lets every other field survive. Verified on mini: map size 0 -> 14, capture_error true on all 3218 jobs, rej_* with_msg 0 -> 3218, and the null-code count held at 7. TestFilterProcessorEnabledDestinationsPreservesFields pins the contract. It sets every ConfigT field non-zero and sweeps with reflection, so adding a field without deciding its filter fate fails the test instead of silently dropping it on the topic. The sampleFilteredSources fixture encoded the old allowlist behaviour and had to change with it; its comment claimed gateway tests depend on it, which is not true, so that is corrected too.
One component answers whether a sync run captures error responses: the pinned per-run decision lives in rsources_sync_settings so every pod and every restart sees the same value (pods restart ~2h and run multi-pod), computed from the component's own backend-config subscription on first miss under a two-argument advisory lock, cached without size limit, cleaned up after 24h. Operator flag, blocklists and the clip/sanitize mechanics move here from the collector.
CollectFailedRecords asks the delegate per aborted record and returns its error - strict: the batch aborts rather than publishing durable failed records with silently empty error text. A collector built without a delegate gets a fail-loud default, never a silent no-op. The collector's own capture settings, bookkeeping and per-publish reporting are deleted.
…ter paths One instance per process, built beside drain-config in the processor and embedded apps, routines on the errgroup, injected via WithSyncSettingDelegate into the two collectors that publish failed records.
The delegate's durable pin supersedes it; the flag no longer rides ParametersT and the processor package returns to stock.
… default Check-order short-circuits, config-index resolution, restart survival, cross-instance races under the advisory lock, concurrent table creation, cleanup, telemetry hygiene, and strict propagation through both router paths.
|
@atzoum implemented as per your review plus what we discussed on the call. The shape is exactly your spec: Gateway and processor are back to stock, zero diff vs master — which surfaced the one place your two asks collide: threading the delegate into every collector constructor would itself touch the gateway. Reconciled by keeping the 3-arg constructors with a fail-loud default (a collector without a delegate errors if it ever collects failed records — no silent path) and injecting the real one only in router/batchrouter via an option. Flagging it since it's the one deliberate deviation from the letter of the review. The multi-pod/2h-restart properties from the call are all pinned by tests on real postgres: restart survival, cross-instance race under the lock with deliberately opposite config indexes (one row, same answer), concurrent table creation on rollout, concurrent cleanup, and absence never cached. Ready for another look. |
Component files 5->3 (config subscription and stubs fold into the main file), the fail-loud constructor unexported, the test probe shares the real constructor's field initialisation instead of hand-rebuilding it, factories fail at construction on a missing SyncSettings, and behavior pinned twice at different layers keeps one pin. Net -135 lines, no design or metric changes.
…1-capture-the-final-error-at-the-failed-records-collector
…actories The factory construction guard caught these two unwired router/batchrouter factories in TestDynamicClusterManager - the one Factory construction site the wiring sweep missed.
…or-at-the-failed-records-collector
atzoum
left a comment
There was a problem hiding this comment.
The description of this pr is what will be recorded in the commit message. Let's keep it short and concise: we are merely adding support for capturing error responses in failed records, this is configurable and we are introducing a mechanism to pin this decision on a per source run id basis, so that configuration changes mid-run don't affect syncs. Then any VERY IMPORTANT design notes should be covered.
…tl for the store The ON CONFLICT DO UPDATE ... RETURNING upsert gives first-writer-wins plus a read for every racer, replacing the advisory-locked transaction. The table moves to sql-migrator, the decision cache to cachettl (no-refresh TTL aligned with the cleanup DELETE), Stop waits for routines before closing the DB, and per-connection capture counters are pre-created off the hot path.
The delegate becomes a method parameter instead of a collector field, removing the option and the fail-loud default stub; a nil delegate errors only when a decision is actually needed. Factories drop the construction panics. Wiring renamed to RsourcesSyncSettings and deduplicated into a setup helper that also honors Router.failedKeysEnabled - disabled deployments open no connection, run no migration and start no goroutine.
Logical replication is never broken while the schema upgrades: the replica target gains new columns before the local publisher does.
…'s telemetry and clocks The migration now runs on its own short-lived pool closed before the serving pool opens - sql-migrator's checked-out connection would otherwise stay parked for the process's life, leaving the cleanup DELETE and every pin upsert contending for the one survivor (regression-tested against the reintroduced defect). Capture counters are created only for enabled connections and memoised on the adopted-pin fallback with one shared tag identity, and row lifetime plus cache TTL both derive from the database clock.
…ocess-config topic Connections now follow the same rule as destinations, so the processor and everything downstream of TopicProcessConfig see only processor-enabled connections. A nil map stays nil rather than becoming empty.
…case-sensitive Verified against gjson v1.19.0: there is no case-insensitive fallback, so Error and error cannot conflate and the exact-key scan collapses to ordered lookups. The empty-input early return goes too - a non-object parse already answers it.
…g it forever WithInstance hands the driver the caller's pool, so closing it was never an option and the checked-out connection stayed InUse for the process's life in every component using the migrator. WithConnection borrows one explicit connection that Close actually releases. The rsources delegate drops its throwaway-pool workaround; its pool regression test now proves the common fix. Also per the same review round: capture counters are created lazily at first use - the config-poll pre-fill is gone.
|
Both rounds applied, replies on every thread. Round 2: a1fa1dc4d…a83cdbfbe — your upsert verbatim in place of the advisory locks, sql-migrator + cachettl, the delegate as a Round 3: 2f71cb6…88b18f496. Connections filtered by CI is fully green on the head. One naming call left for you: |
The connection checkout, the driver setup and each statement now time out after a minute, so a wedged database fails the caller instead of hanging its boot.
|
|
||
| // migrationTimeout bounds each phase of a migration - the connection checkout, the | ||
| // driver setup, and every individual statement. | ||
| const migrationTimeout = time.Minute |
There was a problem hiding this comment.
Better to make this overrideable through config.
There was a problem hiding this comment.
Done - SQLMigrator.timeout, default a minute.
…or-at-the-failed-records-collector
SQLMigrator.timeout, default one minute.
| // record: server pods restart roughly every two hours and several pods share one | ||
| // postgres, so an in-memory-only pin would let one sync's records be split between two | ||
| // answers whenever a pod cycled or a config push landed mid-run. | ||
| type SyncSettingDelegate interface { |
There was a problem hiding this comment.
should this interface be named: ErrRespGetter
🤖 I have created a release *beep* *boop* --- ## [1.86.0-rc.1](v1.85.0...v1.86.0-rc.1) (2026-09-07) ### Features * backend config v2-to-v1 mapper ([#7315](#7315)) ([887f6d2](887f6d2)) * **core:** capture the final recorded error for failed rETL records ([#7295](#7295)) ([f4dc4d9](f4dc4d9)) * per-destination visibility at the destination-filter boundary ([#7283](#7283)) ([3d83f02](3d83f02)) * user_suppression counter via suppressed dummy jobs ([#7325](#7325)) ([77d3d37](77d3d37)) * **warehouse:** support jsonPaths for gcs datalake ([#7333](#7333)) ([e714140](e714140)) ### Bug Fixes * rsources failed-records pagination drops records across failed-key boundaries ([#7329](#7329)) ([0a50439](0a50439)) * **warehouse:** stop logging full schemas on table-level schema mismatch ([#7339](#7339)) ([f244c14](f244c14)) * **warehouse:** upgrade clickhouse v2 driver ([#7332](#7332)) ([e2c5cb9](e2c5cb9)) ### Miscellaneous * **ci:** remove unused Snyk policy file (SEC-409) ([#7317](#7317)) ([d60b3c6](d60b3c6)) * make reporting 413 handling unconditional ([#7313](#7313)) ([d2474e9](d2474e9)) * moving pyt contract tests ([#7327](#7327)) ([8316af2](8316af2)) * **processor:** pipeline attribution in processor stats ([#7326](#7326)) ([3e97f7c](3e97f7c)) * skip consent and connection-mode filtering for replays of non-existent connections ([#7323](#7323)) ([d2474e9](d2474e9)) --- 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>
🤖 I have created a release *beep* *boop* --- ## [1.86.0](v1.85.0...v1.86.0) (2026-09-07) ### Features * backend config v2-to-v1 mapper ([#7315](#7315)) ([887f6d2](887f6d2)) * **core:** capture the final recorded error for failed rETL records ([#7295](#7295)) ([f4dc4d9](f4dc4d9)) * per-destination visibility at the destination-filter boundary ([#7283](#7283)) ([3d83f02](3d83f02)) * user_suppression counter via suppressed dummy jobs ([#7325](#7325)) ([77d3d37](77d3d37)) * **warehouse:** support jsonPaths for gcs datalake ([#7333](#7333)) ([e714140](e714140)) ### Bug Fixes * rsources failed-records pagination drops records across failed-key boundaries ([#7329](#7329)) ([0a50439](0a50439)) * **warehouse:** stop logging full schemas on table-level schema mismatch ([#7339](#7339)) ([f244c14](f244c14)) * **warehouse:** upgrade clickhouse v2 driver ([#7332](#7332)) ([e2c5cb9](e2c5cb9)) ### Miscellaneous * **ci:** remove unused Snyk policy file (SEC-409) ([#7317](#7317)) ([d60b3c6](d60b3c6)) * make reporting 413 handling unconditional ([#7313](#7313)) ([d2474e9](d2474e9)) * moving pyt contract tests ([#7327](#7327)) ([8316af2](8316af2)) * **processor:** pipeline attribution in processor stats ([#7326](#7326)) ([3e97f7c](3e97f7c)) * skip consent and connection-mode filtering for replays of non-existent connections ([#7323](#7323)) ([d2474e9](d2474e9)) --- 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>
What
Adds support for capturing the destination's error response for failed rETL records: stored in a new additive
error_responsecolumn and exposed aserroron the internal v2 failed-records API. Capture is configurable — a global operator flag (default off everywhere), the connection'serrorDetailsConfig.enabledfrom backend config, and operator blocklists.The decision is pinned per source run id in a shared
rsources_sync_settingstable (SyncSettingDelegate, services/rsources), so configuration changes mid-run never affect an in-flight sync: every pod and every restart sees the same answer.Design notes
filterProcessorEnabledDestinationsrebuilt its payload from a field allowlist and droppedConnections(and every newerConfigTfield) fromTopicProcessConfig; it now preserves all fields and filters only destinations.Spec: rudder-specs #109 (
show-all-errors-rudder-server-lld.md) · Linear: PRO-5904