lasdf1234 opened a new issue, #13964:
URL: https://github.com/apache/gravitino/issues/13964

   ### Version
   
   main branch / 1.3.x
   
   ### Describe what's wrong
   
   On multi-node (or multi-replica) startup, `IdpRESTFeature.configure` calls 
`IdpUserGroupManager.initializeConfiguredServiceAdmins`. Each node checks 
whether configured service admins exist, then inserts missing ones. When two 
nodes both observe a missing admin and insert concurrently, one hits the unique 
constraint on `(user_name, deleted_at)` and the duplicate-key error becomes 
`AlreadyExistsException`. That exception currently fails Jetty startup of 
`gravitino-web` (`UNAVAILABLE`), so the API can be unavailable until a later 
restart succeeds.
   
   Bootstrap should treat a concurrent create as success (idempotent): keep the 
existence pre-check, and ignore `AlreadyExistsException` on insert. Do not 
change the normal `addUser` API path.
   
   Reported in production on enterprise `branch-1.3` 
(datastrato/gravitino-enterprise#2723 / DAT-1704).
   
   ### Error message and/or stacktrace
   
   ```text
   Caused by: org.apache.gravitino.exceptions.AlreadyExistsException: IdP user 
admin already exists
        at 
org.apache.gravitino.idp.storage.relational.converters.IdpSQLExceptionConverter.toIdpException(...)
        at 
org.apache.gravitino.idp.storage.service.IdpUserMetaService.insertIdpUser(...)
        at 
org.apache.gravitino.idp.IdpUserGroupManager.initializeConfiguredServiceAdmins(...)
        at 
org.apache.gravitino.idp.web.rest.feature.IdpRESTFeature.configure(...)
   Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value 
violates unique constraint "idp_user_meta_user_name_deleted_at_key"
     Detail: Key (user_name, deleted_at)=(admin, 0) already exists.
   ```
   
   ### How to reproduce
   
   1. Deploy Gravitino with built-in IdP and configured service admins on a 
shared PostgreSQL (or other) entity store.
   2. Start two server nodes at the same time (empty IdP users, or after delete 
of the admin row).
   3. Observe one node may fail startup with `AlreadyExistsException` while the 
other creates the admin successfully.
   
   ### Additional context
   
   - Component: `plugins/idp-basic` 
(`IdpUserGroupManager.initializeConfiguredServiceAdmins`)
   - Fix approach: catch `AlreadyExistsException` only in the bootstrap insert 
loop; leave user-facing create APIs unchanged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to