stjosh / auto_groups

👥 Auto Groups app for Nextcloud
https://apps.nextcloud.com/apps/auto_groups
GNU Affero General Public License v3.0
14 stars 2 forks source link

Duplicate entry 'groupname-username' for key 'oc_group_user.PRIMARY' #76

Closed Shen closed 2 weeks ago

Shen commented 4 months ago

Beforehand: Great app. It saved mit a lot of time. There is an error in my logfiles. I have activated the option to check membership of the auto groups each time you log in:

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'groupname-username' for key 'oc_group_user.PRIMARY'
/path/3rdparty/doctrine/dbal/src/Connection.php - line 1814:

Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()

/path/3rdparty/doctrine/dbal/src/Connection.php - line 1749:

Doctrine\DBAL\Connection->handleDriverException()

/path/3rdparty/doctrine/dbal/src/Connection.php - line 1163:

Doctrine\DBAL\Connection->convertExceptionDuringQuery()

/path/lib/private/DB/Connection.php - line 295:

Doctrine\DBAL\Connection->executeStatement()

/path/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php - line 354:

OC\DB\Connection->executeStatement()

/path/lib/private/DB/QueryBuilder/QueryBuilder.php - line 280:

Doctrine\DBAL\Query\QueryBuilder->execute()

/path/lib/private/Group/Database.php - line 196:

OC\DB\QueryBuilder\QueryBuilder->execute()

/path/lib/private/Group/Group.php - line 192:

OC\Group\Database->addToGroup()

/path/apps/auto_groups/lib/AutoGroupsManager.php - line 121:

OC\Group\Group->addUser("*** sensiti ... *")

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 251:

OCA\AutoGroups\AutoGroupsManager->addAndRemoveAutoGroups()

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 73:

Symfony\Component\EventDispatcher\EventDispatcher->callListeners()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 94:

Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 106:

OC\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/User/Session.php - line 391:

OC\EventDispatcher\EventDispatcher->dispatchTyped()

/path/lib/private/User/Session.php - line 665:

OC\User\Session->completeLogin("*** sensiti ... *")

/path/lib/private/User/Session.php - line 353:

OC\User\Session->loginWithToken("*** sensiti ... *")

/path/lib/private/User/Session.php - line 452:

OC\User\Session->login("*** sensiti ... *")

/path/lib/private/User/Session.php - line 590:

OC\User\Session->logClientIn("*** sensiti ... *")

/path/lib/base.php - line 1150:

OC\User\Session->tryBasicAuthLogin()

/path/ocs/v1.php - line 62:

OC::handleLogin()

/path/ocs/v2.php - line 23:

require_once("/zfsinst/ed ... p")

Verursacht durch Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'groupname-username' for key 'oc_group_user.PRIMARY'
/path/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php - line 103:

Doctrine\DBAL\Driver\PDO\Exception::new()

/path/3rdparty/doctrine/dbal/src/Connection.php - line 1153:

Doctrine\DBAL\Driver\PDO\Statement->execute()

/path/lib/private/DB/Connection.php - line 295:

Doctrine\DBAL\Connection->executeStatement()

/path/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php - line 354:

OC\DB\Connection->executeStatement()

/path/lib/private/DB/QueryBuilder/QueryBuilder.php - line 280:

Doctrine\DBAL\Query\QueryBuilder->execute()

/path/lib/private/Group/Database.php - line 196:

OC\DB\QueryBuilder\QueryBuilder->execute()

/path/lib/private/Group/Group.php - line 192:

OC\Group\Database->addToGroup()

/path/apps/auto_groups/lib/AutoGroupsManager.php - line 121:

OC\Group\Group->addUser("*** sensiti ... *")

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 251:

OCA\AutoGroups\AutoGroupsManager->addAndRemoveAutoGroups()

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 73:

Symfony\Component\EventDispatcher\EventDispatcher->callListeners()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 94:

Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 106:

OC\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/User/Session.php - line 391:

OC\EventDispatcher\EventDispatcher->dispatchTyped()

/path/lib/private/User/Session.php - line 665:

OC\User\Session->completeLogin("*** sensiti ... *")

/path/lib/private/User/Session.php - line 353:

OC\User\Session->loginWithToken("*** sensiti ... *")

/path/lib/private/User/Session.php - line 452:

OC\User\Session->login("*** sensiti ... *")

/path/lib/private/User/Session.php - line 590:

OC\User\Session->logClientIn("*** sensiti ... *")

/path/lib/base.php - line 1150:

OC\User\Session->tryBasicAuthLogin()

/path/ocs/v1.php - line 62:

OC::handleLogin()

/path/ocs/v2.php - line 23:

require_once("/zfsinst/ed ... p")

Verursacht durch PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'groupname-username' for key 'oc_group_user.PRIMARY'
/path/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php - line 101:

PDOStatement->execute()

/path/3rdparty/doctrine/dbal/src/Connection.php - line 1153:

Doctrine\DBAL\Driver\PDO\Statement->execute()

/path/lib/private/DB/Connection.php - line 295:

Doctrine\DBAL\Connection->executeStatement()

/path/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php - line 354:

OC\DB\Connection->executeStatement()

/path/lib/private/DB/QueryBuilder/QueryBuilder.php - line 280:

Doctrine\DBAL\Query\QueryBuilder->execute()

/path/lib/private/Group/Database.php - line 196:

OC\DB\QueryBuilder\QueryBuilder->execute()

/path/lib/private/Group/Group.php - line 192:

OC\Group\Database->addToGroup()

/path/apps/auto_groups/lib/AutoGroupsManager.php - line 121:

OC\Group\Group->addUser("*** sensiti ... *")

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 251:

OCA\AutoGroups\AutoGroupsManager->addAndRemoveAutoGroups()

/path/3rdparty/symfony/event-dispatcher/EventDispatcher.php - line 73:

Symfony\Component\EventDispatcher\EventDispatcher->callListeners()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 94:

Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/EventDispatcher/EventDispatcher.php - line 106:

OC\EventDispatcher\EventDispatcher->dispatch()

/path/lib/private/User/Session.php - line 391:

OC\EventDispatcher\EventDispatcher->dispatchTyped()

/path/lib/private/User/Session.php - line 665:

OC\User\Session->completeLogin("*** sensiti ... *")

/path/lib/private/User/Session.php - line 353:

OC\User\Session->loginWithToken("*** sensiti ... *")

/path/lib/private/User/Session.php - line 452:

OC\User\Session->login("*** sensiti ... *")

/path/lib/private/User/Session.php - line 590:

OC\User\Session->logClientIn("*** sensiti ... *")

/path/lib/base.php - line 1150:

OC\User\Session->tryBasicAuthLogin()

/path/ocs/v1.php - line 62:

OC::handleLogin()

/path/ocs/v2.php - line 23:

require_once("/zfsinst/ed ... p")
stjosh commented 4 months ago

Hi @Shen , thanks for reaching out. I can't reproduce this on my system. From the error, it seems to me that a user should be added to a group it's already part of, but there's actually code that should prevent this, so I'm a bit puzzled. Can you provide more info, like app version and Nextcloud version? Do you use the Nextcloud integrated user database, or do you have external users like SAML/SSO or LDAP? Does this error occur each time a user logs in, or only for some users and on some (e.g., the first) login?

stjosh commented 2 weeks ago

No feedback, closed. Feel free to re-open if you can provide further details.