Repository navigation
feat: add source id isolation for reverse etl - #3496
Merged
Merged
Conversation
Contributor
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3496 +/- ##
===========================================
+ Coverage 88.62% 88.64% +0.01%
===========================================
Files 592 594 +2
Lines 32198 32352 +154
Branches 7655 7697 +42
===========================================
+ Hits 28537 28679 +142
- Misses 3338 3350 +12
Partials 323 323 ☔ View full report in Codecov by Sentry. |
Contributor
|
This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR. |
Contributor
Author
|
closing for #3675 |
krishna2020
previously approved these changes
Sep 11, 2024
krishna2020
approved these changes
Sep 11, 2024
ItsSudip
approved these changes
Sep 11, 2024
|
Merged
6 of 10 tasks
arpl
added a commit
that referenced
this pull request
Oct 22, 2026
…reach their own list (#5705) ## What are the changes introduced in this PR? When two rETL syncs feed the same audience destination and their runs overlap, rows from one sync are sent to the other sync's list, and both runs report success. Cause: rudder-server sends every job of a destination in one `/routerTransform` call. `groupRouterTransformEvents` is meant to split those rows per source job (that was #3496), but it read `ev.context?.sources?.job_id`. Router inputs are `{ message, metadata, destination, connection }`, so `context` is under `message`, and the key was always `'default'`. Every sync on a destination landed in one group, and the batching framework builds the integration from the group's first connection (`processDestinationIntegration.ts`), so every request went to that connection's list. Fix: key on `ev.message?.context?.sources?.job_id`. That is the only place the source job id reaches the router transform: rudder-server's router metadata (`router/types/types.go` `JobMetadataT`) has no source job field. Exposed on `develop` (each takes the list / audience / module from one connection for the whole group): | Destination | Where the target is read | Path | | -- | -- | -- | | Custom Activation (`custom_audience`) | `this.connectionConfig` (endpoint `audienceId`, `isHashRequired`) | batching framework | | Reddit Audience | `audienceId` from `this.connectionConfig` | batching framework | | Iterable Audience | `this.connection` | batching framework | | HubSpot Audience | `audienceId` from `this.connection` | batching framework | | Braze Audience | `customAttributeName` from `this.connectionConfig` | batching framework | | LinkedIn Audience | `audienceId` from the first row of each action group (`transform.ts`) | v0 router | | FB Custom Audience (VDM v2) | `groupedRecordInputs[0].connection` (`recordTransform.ts`) | v0 router | | Google Ads Remarketing Lists, legacy and Data Manager (VDM v2) | `[0].connection` (`recordTransform.ts`, `dataManager/recordTransform.ts`) | v0 router | | Customer.io Audience | `inputs[0].connection` (segment, `id_type`) | v0 router | | Zoho (VDM v2) | `inputs[0].connection` (`object` module, `identifierMappings`) | cdk v2 | | Customer.io (VDM v2 object destination) | `object` from `this.connection` (`vdmV2ObjectDestination.ts`): an event sync's rows went out as person identifies | batching framework | | HubSpot (rETL) | path and `objectType` / `identifierType` from `inputs[0]` (`hs/transform.ts`, `retl-transform.ts`): a companies sync's rows went to the contacts upsert endpoint | v0 router | Gainsight PX, Marketo and Pinterest Audience read each row's own connection and put the target in that row's request, so they were already safe (unchanged here). When the two connections have different `isHashRequired` (Custom Activation, Reddit), the second sync's rows were checked against the first sync's flag and rejected as instrumentation errors ("Hashing is disabled but the value … appears to be unhashed"); nothing was sent unhashed. Explainer: https://rudder-office.fly.dev/docs/audience-wrong-list-concurrent-syncs.html ## What is the related Linear task? Resolves ACT2-1257 ## Please explain the objectives of your changes below - `src/v0/util/index.js`: grouping key fix (one line) and comment. - `src/v0/util/index.test.js`: grouping tests rewritten with the real router input shape. The old tests put `context` at the top level, a shape production never sends, so they passed on the broken key. - A two-connection router component case for every exposed destination: `custom_audience`, `reddit_audience`, `iterable_audience`, `hs_audience`, `braze_audience`, `linkedin_audience`, `fb_custom_audience`, `google_adwords_remarketing_lists` (legacy and Data Manager), `customerio_audience`, `zoho`, `customerio` (person + event objects), `hs` (rETL contacts + companies). Two rows on one destination, each with its own `message.context.sources.job_id`, connection and matching `metadata.sourceId` (the shape rudder-server sends), asserting each request goes to its own list / module. Each case fails on the old key; the only other cases that fail there are the four regrouped fixtures below, which return to their old grouping. ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? Rows that carry different source job ids, or a job id vs none, are now transformed in separate groups for every router destination. That is what #3496 intended. Effects: - Concurrent rETL syncs on one destination become separate vendor batches, each on its own connection (the fix). - Traffic from the stock SDKs and replays carries no `context.sources.job_id`, so its batching is unchanged. Events that do carry one (cloud/ETL extract sources run by rudder-sources, or a client that sets `context.sources.job_id` itself) now batch per job, in smaller batches. - A batch that mixes rETL rows with event-stream rows now goes out as two batches, and router output order can change. rudder-server validates router responses as a set of job ids, so no job is dropped or mis-attributed. - Delivery order for one user can change when that user's rows sit in two groups of one router call. rudder-server sends batched requests sorted by their lowest job id (`router/worker.go:442-444`), so with SDK rows j1, j3 in one group and an rETL row j2 in another, `[j1, j3]` is delivered before `[j2]` and j2's older value lands last, even when every request succeeds. If the second request fails, j3 is already delivered while j2 retries. Before, all three shared one request. Groups of an audience destination write different lists, so this matters only for destinations that mix one user's rETL and event-stream rows; dynamic-config grouping already behaves this way. - Braze with `supportDedup`: each group builds its own dedup lookup against Braze's current state (`braze/transform.ts:618-630`) and groups run concurrently, so when one user's rETL row and SDK row land in the same router call, the SDK group can drop the newer update as "Duplicate user detected". Rare; noted rather than handled here. Four existing fixtures had such mixes and were updated: `marketo_static_list` and `customerio_audience` (reorder only), `mailchimp` and `google_adwords_offline_conversions` (one batch becomes two, same rows and payloads). ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. `groupRouterTransformEvents` (shared by `nativeIntegration.ts` and `cdkV2Integration.ts`): grouping key reads the job id from `message.context.sources.job_id` instead of the non-existent top-level `context`. ### Any technical or performance related pointers to consider with the change? - Smaller vendor batches only where one router call holds rows from several source jobs (concurrent rETL syncs; cloud/ETL or profiles sources that stamp `context.sources.job_id` sharing a destination with other traffic). At most one extra partial batch per extra group. - `google_adwords_offline_conversions` store sales: a mixed call now creates one offline user data job per group instead of one shared job. - Known edge, not changed here: a user transformation on an rETL connection that rebuilds the message without `context.sources` puts that sync's rows back in the default group. ### Verification - Unit: `src/v0/util/index.test.js` 223/223. - Component: `npm run test:ts -- component --feature=router` 593 passed, 1 skipped. - `npm test -- src/v0 src/services src/cdk src/v1`: 3293 passed. - `check:secret-paths` against integrations-config `main`: no drift. - Local stack (rudder-mini), one Custom Activation destination, two mirror connections `LIST_A` / `LIST_B` from two 500-row tables, both full syncs started in the same second: | Transformer | `/LIST_A` | `/LIST_B` | Requests carrying the other sync's rows | Both runs reported | | -- | -- | -- | -- | -- | | stock `develop` image (old key) | 1,000 (500 from table B) | 0 | 5 | 500 succeeded, 0 failed | | this branch @ 98cf63f | 500, all table A | 500, all table B | 0 | 500 succeeded, 0 failed | ### Pre-ready review Independent review before opening, then a five-lens review panel (security, correctness, product, ops, coherence) with blinded adversarial checks on each finding and load-bearing claim. Findings and rulings: - Important, fixed: the first version keyed on `metadata.sourceJobId` first, and the new component cases only set that field. rudder-server never sends it on router requests, so the tests covered a path production doesn't take. Fixed in 98cf63f: key only on the message job id; cases now use the shape the router sends. - Minor, fixed: comment overstated "event-stream jobs share one group"; reworded. Fixture `metadata.sourceId` now matches each row's connection. - Should-fix, fixed: the first draft listed 5 exposed destinations; LinkedIn, FB Custom Audience, Google Ads Remarketing Lists (both paths), Customer.io Audience and Zoho have the same pattern. Review on the PR then added Customer.io (VDM v2 objects) and HubSpot rETL. Confirmed by executing two-connection inputs on base vs head, and each now has a test. - Nit, documented above: per-user delivery order across groups. - Minor, noted above: user transformations that drop `context.sources`. A possible follow-up is to also key rETL rows on `metadata.sourceId` (which the router does send) so a transformation cannot merge two syncs. - Not an issue: two connections cannot share a `job_id` (config-backend starts each rETL sync with its connection id; `unique_source_destination` on connections), and one connection keeps one `job_id` across runs and retries (checked in live `rt_jobs`). <hr> ### Developer checklist - [x] My code follows the style guidelines of this project - [x] **No breaking changes are being introduced.** - [x] All related docs linked with the PR? - [x] All changes manually tested? - [ ] Any documentation changes needed with this change? - [ ] Is the PR limited to 10 file changes? (32: 2 source/unit files, 30 component fixtures) - [x] Is the PR limited to one linear task? - [x] Are relevant unit and component test-cases added in **new readability format**? ### Reviewer checklist - [ ] Is the type of change in the PR title appropriate as per the changes? - [ ] Verified that there are no credentials or confidential data exposed with the changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.



What are the changes introduced in this PR?
This is for rETL connections for supporting job run level isolation
What is the related Linear task?
Resolves INT-2299, Resolves INT-2300, Resolves INT-2519
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.