-
Type:
Task
-
Resolution: Unresolved
-
Priority:
High
-
Affects Version/s: None
-
Platform
-
Prod
When two or more application servers (identity-api) point to the same database, beneficiary registration fails intermittently with a duplicate key constraint violation on the i_beneficiarymapping table.
Error
java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '37607628' for key 'i_beneficiarymapping.BenRegId_UNIQUE'
Root Cause
The registration ID allocation used an in-memory ArrayDeque queue inside IdentityService. When the queue was empty, each server independently fetched the same top 10,000 unprovisioned/unreserved rows from m_beneficiaryregidmapping into its local queue. Since neither server had committed a reserved=true update at that point, both queues held identical IDs. Concurrent registrations from the two servers then attempted to insert the same BenRegId, causing the constraint violation.
Impact
- Beneficiary registration fails silently under multi-server deployments
- Affects all AMRIT applications that register beneficiaries via identity-api
- Occurs only when two or more servers share the same database instance (Now get in Assam_Prod_Linux)