Bug #25123
Updated by Clark ANDRIANASOLO 5 months ago
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 : <pre> 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 </pre> 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.