Hello, I am running Phoenix 12.35.0 on Kubernetes with keycloak auth and occassionally run into the below error "Email in Use". It clears after I remove the user from the DB or from the users section in the UI. Any idea why this happens? It reoccurs again after a while and I need to repeat this process
馃挕聽Hint: Mention RunLLM in the thread for followups.
The error you report in the your message differs from the one in the screenshot
It sounds like this consistently happens rather than being a one-off issue?
That error means Phoenix鈥檚 OAuth callback got a (client_id, sub) pair it doesn鈥檛 recognize, but the email in the token already belongs to an existing Phoenix user tied to a different sub. Deleting the row clears the email collision; next login creates a fresh row with the current sub. So something on the Keycloak side is causing the sub (Keycloak鈥檚 internal user UUID) to change for that person over time. Before you delete the row next time, can you grab:
SELECT email, oauth2_client_id, oauth2_user_id, updated_at
FROM users
WHERE email = '<affected email>';If oauth2_user_id (or oauth2_client_id) is different on each recurrence, that confirms it.
Thanks for confirming. Keycloak鈥檚 sub should already be stable for a given user. If it is changing around pod restarts, you can check the folowing. 1. Persistence first. Make sure Keycloak鈥檚 DB is actually surviving restarts. If the pod is using ephemeral storage, or the external DB / PVC is not really persistent, users can get recreated with new internal UUIDs. 2. Startup import / reconcile path. Check whether anything on startup is recreating users: kc.sh import --override, partial import, Helm/operator bootstrap jobs, init containers, or other automation. --import-realm by itself should normally skip an existing realm, so I鈥檇 look more for overwrite / reconcile behavior than --import-realm alone. 3. LDAP/AD federation + Keycloak version. If these are LDAP/AD-backed users and you鈥檙e on Keycloak 24.0.1 or 24.0.2, keycloak#28248 is worth checking. That regression was fixed in 24.0.3 and could recreate federated users on certain update paths. 4. Stable federation ID. If you are using LDAP/AD federation, confirm the provider is using a stable unique attribute such as entryUUID (OpenLDAP) or objectGUID (AD), and that the federation settings are the same after restart.
