fix: TT-16778 GORM v2 table sharding bug#948
Conversation
|
This PR fixes a critical bug in the SQL-based data pumps where GORM v2's method chaining order caused analytics data to be written to the default table instead of the correct date-sharded table. Files Changed Analysis
Architecture & Impact AssessmentWhat this PR accomplishes: Key technical changes introduced: sequenceDiagram
participant P as Pump
participant G as GORM
participant DB as Database
Note over P, G: Before Fix
P->>G: .Table("sharded_table")
P->>G: .WithContext(ctx)
P->>G: .Create(data)
G-->>DB: INSERT INTO "default_table" ...
Note right of DB: Incorrect: .Table() was ignored
Note over P, G: After Fix
P->>G: .WithContext(ctx)
P->>G: .Table("sharded_table")
P->>G: .Create(data)
G-->>DB: INSERT INTO "sharded_table" ...
Note right of DB: Correct
Affected system components:
Scope Discovery & Context ExpansionThe bug's impact is localized to the Metadata
Powered by Visor from Probelabs Last updated: 2026-03-10T06:51:51.645Z | Triggered by: pr_opened | Commit: e39bc8d 💡 TIP: You can chat with Visor using |
Architecture Issues (1)
Architecture Issues (1)
Powered by Visor from Probelabs Last updated: 2026-03-10T06:51:42.579Z | Triggered by: pr_opened | Commit: e39bc8d 💡 TIP: You can chat with Visor using |
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
Superseded by #949 |
Problem / Task
In
SQLAggregatePump,SQLPump, andGraphSQLPump, the.WithContext(ctx)call drops the previously applied.Table(table)modifier. This causes theINSERTstatement to target the default table instead of the sharded table.Changes
The fix is to chain the
.Table(table)modifier after.WithContext(ctx)so that theINSERTstatement correctly targets the sharded table.Testing
Added unit tests to verify the fix.
Requested by: @U3P2L4XNE | Trace: 04efb72f02ec22605b4e0aba22e102f6
Generated with Tyk AI Assistant