Skip to content

fix: prevent member identity existence check from timing out - #4248

Merged
skwowet merged 3 commits into
mainfrom
fix/member-identity-timeout
Jun 22, 2026
Merged

fix: prevent member identity existence check from timing out#4248
skwowet merged 3 commits into
mainfrom
fix/member-identity-timeout

Conversation

@skwowet

@skwowet skwowet commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes 500 query timeouts on PUT /member/:memberId/identity caused by checkMemberIdentityExistence performing 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

  • Rewrite checkMemberIdentityExistence to require type and query by platform, type, and lower(value)
  • Pass type from create, createMultiple, and update in memberIdentityService
  • On update, return 404 when the identity id is not found, resolve the effective identity key from the patch and current row, and only 409 when a different member owns the identity

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>
@skwowet skwowet self-assigned this Jun 22, 2026
Copilot AI review requested due to automatic review settings June 22, 2026 10:39
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 checkMemberIdentityExistence to require type and query by platform, type, and lower(value) (matching existing indexes for active identities).
  • Updated MemberIdentityService create/createMultiple/update to pass type, 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.

Comment thread services/libs/data-access-layer/src/members/identities.ts Outdated
Comment thread services/libs/data-access-layer/src/members/identities.ts Outdated
Comment thread backend/src/services/member/memberIdentityService.ts Outdated
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 22, 2026 11:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@skwowet
skwowet merged commit d64cde5 into main Jun 22, 2026
12 checks passed
@skwowet
skwowet deleted the fix/member-identity-timeout branch June 22, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants