fix: prevent member identity existence check from timing out - #4248
Conversation
Use platform, type, and case-insensitive value matching to leverage existing indexes and avoid full table scans. 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. |
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses PUT /member/:memberId/identity 500s caused by a slow checkMemberIdentityExistence query by rewriting it to use an indexed lookup on (platform, type, lower(value)) and updating backend call sites to always pass type, plus improving update behavior (404 on missing identity id; 409 only when another member owns the identity).
Changes:
- Rewrote
checkMemberIdentityExistenceto requiretypeand query byplatform,type, andlower(value)(matching existing indexes for active identities). - Updated
MemberIdentityServicecreate/createMultiple/update to passtype, and improved update conflict detection + missing-id handling (404). - Minor response-shaping changes for the existence-check query (now selects only
id+memberId).
Note: the PR title is missing the required JIRA key suffix format type: description (CM-XXX) per .claude/rules/commit-workflow.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| services/libs/data-access-layer/src/members/identities.ts | Updates the identity existence query to be index-friendly and requires type. |
| backend/src/services/member/memberIdentityService.ts | Threads type into existence checks and improves update behavior (404/409 handling). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Summary
Fixes 500 query timeouts on
PUT /member/:memberId/identitycaused bycheckMemberIdentityExistenceperforming a full table scan on ~25M rows. The check now uses an indexed query aligned with DB unique constraints and returns 409 quickly when an identity already exists on another profile.Changes
checkMemberIdentityExistenceto requiretypeand query byplatform,type, andlower(value)typefromcreate,createMultiple, andupdateinmemberIdentityService