Bug #25123
closedAuthentication happens twice with same session id
Description
When logging in as a Rudder user, I successfully log in but I see an error log about a database unique constraint violation error on (userid, sessionid)
from the UserRepository#logStartSession
method :
2024-07-09 13:26:03+0000 INFO application - Rudder authentication attempt for principal 'admin' with backend 'file': success 2024-07-09 13:26:03.351:WARN :oejs.HttpChannel:qtp125622176-20: /rudder/j_spring_security_check Exception in thread "zio-fiber-1175" com.normation.errors$SystemError: SystemError(Error when saving session 'node06kqmzsp107cm1ezn7dr0uf1tw2' info for user 'admin',org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "usersessions_pkey"| Detail: Key (userid, sessionid)=(admin, node06kqmzsp107cm1ezn7dr0uf1tw2) already exists.)|?at zio.interop.ZioMonadErrorE.raiseError.trace(cats.scala:628)|?at cats.Monad.map(Monad.scala:35)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.Monad.map(Monad.scala:35)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.Monad.map(Monad.scala:35)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.Monad.map(Monad.scala:35)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.Monad.map(Monad.scala:35)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.free.Free.foldMap(Free.scala:166)|?at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604)|?at cats.effect.kernel.Resource.fold(Resource.scala:173)|?at com.normation.rudder.db.Doobie.transactIOResult(Doobie.scala:93)|?at com.normation.rudder.users.JdbcUserRepository.logStartSession(UserRepository.scala:622)|?at com.normation.zio.ZioRuntime.unsafeRun(ZioCommons.scala:445) at zio.interop.ZioMonadErrorE.raiseError.trace(cats.scala:628) at cats.Monad.map(Monad.scala:35) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.Monad.map(Monad.scala:35) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.Monad.map(Monad.scala:35) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.Monad.map(Monad.scala:35) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.Monad.map(Monad.scala:35) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.free.Free.foldMap(Free.scala:166) at zio.interop.ZioMonadError.tailRecM.loop(cats.scala:604) at cats.effect.kernel.Resource.fold(Resource.scala:173) at com.normation.rudder.db.Doobie.transactIOResult(Doobie.scala:93) at com.normation.rudder.users.JdbcUserRepository.logStartSession(UserRepository.scala:622) at com.normation.zio.ZioRuntime.unsafeRun(ZioCommons.scala:445) 2024-07-09 13:26:10+0000 INFO application - Rudder authentication attempt for principal 'admin' with backend 'file': success
The database error suggests that we are executing the authenticate
method twice with the same context (session and user).
We would like to know in which cases this happens, and at least avoid throwing this error.
Updated by Clark ANDRIANASOLO 6 months ago
- Related to Bug #24017: Webapp can fail to start with null sessionid error added
Updated by Clark ANDRIANASOLO 6 months ago
- File deleted (
clipboard-202407091608-isen3.png)
Updated by Clark ANDRIANASOLO 6 months ago
- starting a long "archive export" process
- restarting the webapp in the middle of the process
- logging in again
Updated by Vincent MEMBRÉ 5 months ago
- Target version changed from 8.1.6 to 8.1.7
Updated by Clark ANDRIANASOLO 4 months ago
Maybe this is due to session termination issues as described here : https://docs.spring.io/spring-security/reference/5.8/servlet/authentication/session-management.html#properly-clearing-authentication ?
Updated by Clark ANDRIANASOLO 4 months ago
- Status changed from New to In progress
- Assignee set to Clark ANDRIANASOLO
Updated by Clark ANDRIANASOLO 4 months ago
- Status changed from In progress to Pending technical review
- Assignee changed from Clark ANDRIANASOLO to François ARMAND
- Pull Request set to https://github.com/Normation/rudder/pull/5818
Updated by Clark ANDRIANASOLO 4 months ago
- Status changed from Pending technical review to Pending release
- Priority changed from 97 to 96
Applied in changeset rudder|50b3f5c16b5f1aa86e3ae2cc7ee0426f531f6358.
Updated by Clark ANDRIANASOLO 3 months ago
- Priority changed from 96 to 95
- Fix check changed from To do to Checked
Updated by Vincent MEMBRÉ 3 months ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 8.1.7 which was released today.