fix: serialize member enrichment org savepoints#4071
Conversation
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
2 similar comments
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR fixes intermittent savepoint "... " does not exist failures during member enrichment by removing parallel organization writes within a single pg-promise transaction (which can create conflicting nested savepoints) and deferring organization sync until after the transaction has committed.
Changes:
- Serialize
findOrCreateOrganizationcalls (and related identity/merge-suggestion handling) by removing the priorPromise.all(...)pattern. - Track organization IDs that need syncing during the transaction and run
syncOrganizationonly after the outer transaction completes (deduped).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Muawiya-contact <contactmuawia@gmail.com>
Summary
Fixes a
savepoint "... " does not existfailure in member enrichment.The issue came from running multiple organization writes in parallel inside one DB transaction. Each write could create nested savepoints, and one rollback could invalidate another in-flight savepoint.
This PR makes those organization writes run sequentially and syncs after the DB transaction commits.
Note
Medium Risk
Changes transaction execution by making organization upserts sequential and moving
syncOrganizationoutside the member update transaction, which could affect throughput and timing but reduces risk of transactional savepoint conflicts.Overview
Prevents member enrichment failures caused by parallel organization writes inside a single DB transaction by serializing
findOrCreateOrganizationcalls (removing the in-transactionPromise.allpattern).Collects created/updated organization IDs during the transaction and triggers
syncOrganizationafter the transaction commits, deduping IDs and isolating sync failures from DB writes.Reviewed by Cursor Bugbot for commit 4e4dd48. Bugbot is set up for automated code reviews on this repo. Configure here.