Repository navigation
fix(billing): make profile reads transaction-aware - #5433
Conversation
GetProfile, GetDefaultProfile and ListProfiles queried through the base ent client, so inside a transaction (e.g. GetCustomerOverride) they took a second pool connection. With in-flight requests >= pool size every request held one connection and waited on another. Use entutils.TransactingRepo like the other profile methods. Signed-off-by: Jeff Hoffer <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Thank you! |
GetProfile,GetDefaultProfileandListProfilesinopenmeter/billing/adapter/profile.goqueried through the base ent client instead ofentutils.TransactingRepo. Inside a transaction (for exampleGetCustomerOverride->resolveProfileWorkflow) they took a second pool connection. When in-flight requests reach the pool size, each request holds one connection and waits for another, and the pool deadlocks. This is the failure #5255 diagnosed in the stress test and left as separate work.entutils.TransactingRepo, matching the other profile methods.TestProfileReadsReuseTransactionConnection: with the pool limited to one connection, the three reads inside a transaction complete. It fails withcontext deadline exceededwithout the change.go build ./...,./openmeter/billing/...and./test/billing/pass against Postgres.Refs #5255
Summary by CodeRabbit


Confidence Score: 5/5
This PR appears safe to merge.Summary
Makes
GetProfile,GetDefaultProfile, andListProfilesreuse the caller’s transaction connection.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Profile read] --> B{Transaction in context?} B -->|Yes| C[Use existing transaction connection] B -->|No| D[Use original database client] C --> E[Read profile and workflow data] D --> E E --> F[Return billing values]Reviews (1) · Last reviewed commit: "fix(billing): make profile reads transac..." · Reviewed by Greptile