Integrity constraint violation: 1062 Duplicate entry

Support intro

Hi all,

I’ve been annoying for many hours with a problem that I can’t get on with.
Everything always worked flawlessly until suddenly 1 from 3 users can´t login.
Username is “alex”.
Error says: “Interner Serverfehler” (which means “internal server error”).
Tried to reset the password via password-forgot-option and I tried to reset the password with admin account. Both failed with an error.
In all cases (logon, pw reset) there is the same error in log:

[index] Fehler: OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alex-password::logincredentials/credentials' for key 'stocred_ui' at <<closure>>

Nextcloud version (eg, 20.0.5): 26.0.0 RC2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.41
PHP version (eg, 7.4): 8.2.3

It´s behind HAProxy (pfSense).

Is this the first time you’ve seen this error? (Y/N): Y

The output of your Nextcloud log in Admin > Logging:

[index] Fehler: OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alex-password::logincredentials/credentials' for key 'stocred_ui' at <<closure>>

 0. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 328
    OC\DB\Exceptions\DbalException::wrap()
 1. /var/www/nextcloud/lib/private/DB/Connection.php line 396
    OC\DB\QueryBuilder\QueryBuilder->executeStatement()
 2. /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php line 114
    OC\DB\Connection->setValues()
 3. /var/www/nextcloud/lib/private/Security/CredentialsManager.php line 72
    OC\DB\ConnectionAdapter->setValues()
 4. /var/www/nextcloud/apps/files_external/lib/Listener/StorePasswordListener.php line 73
    OC\Security\CredentialsManager->store()
 5. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\Files_External\Listener\StorePasswordListener->handle()
 6. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
 7. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
 8. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
 9. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
10. /var/www/nextcloud/lib/private/Server.php line 628
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
11. <<closure>>
    OC\Server->OC\{closure}("*** sensitive parameters replaced ***")
12. /var/www/nextcloud/lib/private/Hooks/EmitterTrait.php line 105
    call_user_func_array()
13. /var/www/nextcloud/lib/private/Hooks/PublicEmitter.php line 40
    OC\Hooks\BasicEmitter->emit()
14. /var/www/nextcloud/lib/private/User/Session.php line 400
    OC\Hooks\PublicEmitter->emit()
15. /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php line 43
    OC\User\Session->completeLogin("*** sensitive parameters replaced ***")
16. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\CompleteLoginCommand->process()
17. /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php line 60
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
18. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\LoggedInCheckCommand->process()
19. /var/www/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php line 68
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
20. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\EmailLoginCommand->process()
21. /var/www/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php line 53
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
22. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UidLoginCommand->process()
23. /var/www/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php line 57
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
24. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UserDisabledCheckCommand->process()
25. /var/www/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php line 52
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
26. /var/www/nextcloud/lib/private/Authentication/Login/Chain.php line 107
    OC\Authentication\Login\PreLoginHookCommand->process()
27. /var/www/nextcloud/core/Controller/LoginController.php line 326
    OC\Authentication\Login\Chain->process()
28. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OC\Core\Controller\LoginController->tryLogin("*** sensitive parameters replaced ***")
29. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
30. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
31. /var/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
32. /var/www/nextcloud/lib/base.php line 1051
    OC\Route\Router->match()
33. /var/www/nextcloud/index.php line 36
    OC::handleRequest()

Caused by:

Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alex-password::logincredentials/credentials' for key 'stocred_ui' at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1814
    Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1749
    Doctrine\DBAL\Connection->handleDriverException()
 2. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1163
    Doctrine\DBAL\Connection->convertExceptionDuringQuery()
 3. /var/www/nextcloud/lib/private/DB/Connection.php line 297
    Doctrine\DBAL\Connection->executeStatement()
 4. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 354
    OC\DB\Connection->executeStatement()
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 280
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 326
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /var/www/nextcloud/lib/private/DB/Connection.php line 396
    OC\DB\QueryBuilder\QueryBuilder->executeStatement()
 8. /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php line 114
    OC\DB\Connection->setValues()
 9. /var/www/nextcloud/lib/private/Security/CredentialsManager.php line 72
    OC\DB\ConnectionAdapter->setValues()
10. /var/www/nextcloud/apps/files_external/lib/Listener/StorePasswordListener.php line 73
    OC\Security\CredentialsManager->store()
11. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\Files_External\Listener\StorePasswordListener->handle()
12. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
13. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
14. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
15. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
16. /var/www/nextcloud/lib/private/Server.php line 628
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
17. <<closure>>
    OC\Server->OC\{closure}("*** sensitive parameters replaced ***")
18. /var/www/nextcloud/lib/private/Hooks/EmitterTrait.php line 105
    call_user_func_array()
19. /var/www/nextcloud/lib/private/Hooks/PublicEmitter.php line 40
    OC\Hooks\BasicEmitter->emit()
20. /var/www/nextcloud/lib/private/User/Session.php line 400
    OC\Hooks\PublicEmitter->emit()
21. /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php line 43
    OC\User\Session->completeLogin("*** sensitive parameters replaced ***")
22. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\CompleteLoginCommand->process()
23. /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php line 60
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
24. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\LoggedInCheckCommand->process()
25. /var/www/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php line 68
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
26. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\EmailLoginCommand->process()
27. /var/www/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php line 53
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
28. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UidLoginCommand->process()
29. /var/www/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php line 57
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
30. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UserDisabledCheckCommand->process()
31. /var/www/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php line 52
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
32. /var/www/nextcloud/lib/private/Authentication/Login/Chain.php line 107
    OC\Authentication\Login\PreLoginHookCommand->process()
33. /var/www/nextcloud/core/Controller/LoginController.php line 326
    OC\Authentication\Login\Chain->process()
34. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OC\Core\Controller\LoginController->tryLogin("*** sensitive parameters replaced ***")
35. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
36. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
37. /var/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
38. /var/www/nextcloud/lib/base.php line 1051
    OC\Route\Router->match()
39. /var/www/nextcloud/index.php line 36
    OC::handleRequest()

Caused by:

Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alex-password::logincredentials/credentials' for key 'stocred_ui' at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php line 103
    Doctrine\DBAL\Driver\PDO\Exception::new()
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1153
    Doctrine\DBAL\Driver\PDO\Statement->execute()
 2. /var/www/nextcloud/lib/private/DB/Connection.php line 297
    Doctrine\DBAL\Connection->executeStatement()
 3. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 354
    OC\DB\Connection->executeStatement()
 4. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 280
    Doctrine\DBAL\Query\QueryBuilder->execute()
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 326
    OC\DB\QueryBuilder\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/DB/Connection.php line 396
    OC\DB\QueryBuilder\QueryBuilder->executeStatement()
 7. /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php line 114
    OC\DB\Connection->setValues()
 8. /var/www/nextcloud/lib/private/Security/CredentialsManager.php line 72
    OC\DB\ConnectionAdapter->setValues()
 9. /var/www/nextcloud/apps/files_external/lib/Listener/StorePasswordListener.php line 73
    OC\Security\CredentialsManager->store()
10. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\Files_External\Listener\StorePasswordListener->handle()
11. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
12. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
13. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
14. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
15. /var/www/nextcloud/lib/private/Server.php line 628
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
16. <<closure>>
    OC\Server->OC\{closure}("*** sensitive parameters replaced ***")
17. /var/www/nextcloud/lib/private/Hooks/EmitterTrait.php line 105
    call_user_func_array()
18. /var/www/nextcloud/lib/private/Hooks/PublicEmitter.php line 40
    OC\Hooks\BasicEmitter->emit()
19. /var/www/nextcloud/lib/private/User/Session.php line 400
    OC\Hooks\PublicEmitter->emit()
20. /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php line 43
    OC\User\Session->completeLogin("*** sensitive parameters replaced ***")
21. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\CompleteLoginCommand->process()
22. /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php line 60
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
23. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\LoggedInCheckCommand->process()
24. /var/www/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php line 68
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
25. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\EmailLoginCommand->process()
26. /var/www/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php line 53
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
27. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UidLoginCommand->process()
28. /var/www/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php line 57
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
29. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UserDisabledCheckCommand->process()
30. /var/www/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php line 52
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
31. /var/www/nextcloud/lib/private/Authentication/Login/Chain.php line 107
    OC\Authentication\Login\PreLoginHookCommand->process()
32. /var/www/nextcloud/core/Controller/LoginController.php line 326
    OC\Authentication\Login\Chain->process()
33. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OC\Core\Controller\LoginController->tryLogin("*** sensitive parameters replaced ***")
34. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
35. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
36. /var/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
37. /var/www/nextcloud/lib/base.php line 1051
    OC\Route\Router->match()
38. /var/www/nextcloud/index.php line 36
    OC::handleRequest()

Caused by:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'alex-password::logincredentials/credentials' for key 'stocred_ui' at <<closure>>

 0. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php line 101
    PDOStatement->execute()
 1. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1153
    Doctrine\DBAL\Driver\PDO\Statement->execute()
 2. /var/www/nextcloud/lib/private/DB/Connection.php line 297
    Doctrine\DBAL\Connection->executeStatement()
 3. /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 354
    OC\DB\Connection->executeStatement()
 4. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 280
    Doctrine\DBAL\Query\QueryBuilder->execute()
 5. /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 326
    OC\DB\QueryBuilder\QueryBuilder->execute()
 6. /var/www/nextcloud/lib/private/DB/Connection.php line 396
    OC\DB\QueryBuilder\QueryBuilder->executeStatement()
 7. /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php line 114
    OC\DB\Connection->setValues()
 8. /var/www/nextcloud/lib/private/Security/CredentialsManager.php line 72
    OC\DB\ConnectionAdapter->setValues()
 9. /var/www/nextcloud/apps/files_external/lib/Listener/StorePasswordListener.php line 73
    OC\Security\CredentialsManager->store()
10. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\Files_External\Listener\StorePasswordListener->handle()
11. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
12. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
13. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
14. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
15. /var/www/nextcloud/lib/private/Server.php line 628
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
16. <<closure>>
    OC\Server->OC\{closure}("*** sensitive parameters replaced ***")
17. /var/www/nextcloud/lib/private/Hooks/EmitterTrait.php line 105
    call_user_func_array()
18. /var/www/nextcloud/lib/private/Hooks/PublicEmitter.php line 40
    OC\Hooks\BasicEmitter->emit()
19. /var/www/nextcloud/lib/private/User/Session.php line 400
    OC\Hooks\PublicEmitter->emit()
20. /var/www/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php line 43
    OC\User\Session->completeLogin("*** sensitive parameters replaced ***")
21. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\CompleteLoginCommand->process()
22. /var/www/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php line 60
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
23. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\LoggedInCheckCommand->process()
24. /var/www/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php line 68
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
25. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\EmailLoginCommand->process()
26. /var/www/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php line 53
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
27. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UidLoginCommand->process()
28. /var/www/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php line 57
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
29. /var/www/nextcloud/lib/private/Authentication/Login/ALoginCommand.php line 39
    OC\Authentication\Login\UserDisabledCheckCommand->process()
30. /var/www/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php line 52
    OC\Authentication\Login\ALoginCommand->processNextOrFinishSuccessfully()
31. /var/www/nextcloud/lib/private/Authentication/Login/Chain.php line 107
    OC\Authentication\Login\PreLoginHookCommand->process()
32. /var/www/nextcloud/core/Controller/LoginController.php line 326
    OC\Authentication\Login\Chain->process()
33. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OC\Core\Controller\LoginController->tryLogin("*** sensitive parameters replaced ***")
34. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
35. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
36. /var/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
37. /var/www/nextcloud/lib/base.php line 1051
    OC\Route\Router->match()
38. /var/www/nextcloud/index.php line 36
    OC::handleRequest()

POST /index.php/login

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '*******',
  'passwordsalt' => '*******',
  'secret' => '*******',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.*******.org',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '26.0.0.9',
  'overwrite.cli.url' => 'https://nextcloud.*******.org',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '*******',
  'installed' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'logfilemode' => 416,
  'loglevel' => 2,
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => '*******',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => '*******',
  'mail_smtphost' => '*******',
  'mail_smtpport' => '465',
  'mail_smtpname' => '*******',
  'mail_smtppassword' => '*******',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'default_phone_region' => 'DE',
  'trashbin_retention_obligation' => 'auto, 7',
  'updater.release.channel' => 'stable',
  'updater.secret' => '*******',
  'filesystem_check_changes' => 1,
  'theme' => '',
  'simpleSignUpLink.shown' => false,
  'app_install_overwrite' =>
  array (
    0 => 'cookbook',
  ),
);

Does anyone have an idea what the problem could be?

Hello,

I have the exact same error when a user tries to login.

MySql logs:

SELECT `credentials` FROM `oc_storages_credentials` WHERE (`identifier` = 'password::logincredentials/credentials') AND (`user` = 'bob')
INSERT INTO `oc_storages_credentials` (`user`, `identifier`, `credentials`) VALUES('bob', 'password::logincredentials/credentials', '***hidden***')

The first query returns one result.
So the second query should be :

UPDATE `oc_storages_credentials` SET `credentials` = '***hidden***' WHERE (`identifier` = 'password::logincredentials/credentials') AND (`user` = 'bob')

Nextcloud version: 26.0.0
Operating system and version : Ubuntu 18.04.6
Apache or nginx version : Apache 2.4.56
PHP version : 8.1.17
Is this the first time you’ve seen this error ? Y

Note :
Users connect using LDAP and the problem occurs if the password has changed.

Edited on 04/17/2023 :
The replacement query should not be a REPLACE but an UPDATE query.

Hi,
I am getting the same error for one user after the upgrade to NC 26.
@samt - did you manage to fix the issue? I see that

SELECT `credentials` FROM `oc_storages_credentials` WHERE (`identifier` = 'password::logincredentials/credentials') AND (`user` = 'username')

returns one record, however I don’t know what to do next (just run the REPLACE INTO block?).

Nextcloud version: 26.0.0
Operating system and version : Ubuntu 22.04.2 LTS
Apache or nginx version : Apache 2.4.57
PHP version : 8.1.18
Is this the first time you’ve seen this error ? Y

Thanks!

To solve the problem, I deleted the row returned by the SELECT by running the following query directly in the database:

DELETE FROM `oc_storages_credentials` WHERE (`identifier` = 'password::logincredentials/credentials') AND (`user` = 'bob')

Then the user regains normal access to the application, until he changes his password.

The problem is that there may be external shares that depend on these stored credentials so I’m not recommending my solution but rather waiting for a fix.

More securely, you can enable SQL logging and then retrieve the value of the ‘credentials’ column of the problematic query:

INSERT INTO `oc_storages_credentials` (`user`, `identifier`, `credentials`) VALUES('bob', 'password::logincredentials/credentials', '***hidden***')

And inject the following query instead:

UPDATE `oc_storages_credentials` SET `credentials` = '***hidden***' WHERE (`identifier` = 'password::logincredentials/credentials') AND (`user` = 'bob')

This method is more secure but requires logging SQL queries.

A ticket has been opened on the GitHub repo :

Thanks for the detailed explanation! In my case it is a production environment without LDAP, so I will need to duplicate the setup to play around with database updates. The user still has access to his data though the mobile app (which was already linked to the account before the upgrade) - I will create a temporary account so he can share the files from the original one until the bug is closed. I would prefer some proper fix rather than manual database changes…

Any update to this? I’m currently running into the same problem.

Your workaround for deleting the row out of the DB lets the user back in, but now they need to recreate their external storage links. Thank you very much for this though as I really helped!

Hello jp57,
As mentioned in my bug report, the problem has been fixed since version 26.0.2 RC1. So you need to update NextCloud.

Same Problem with Version Nextcloud Hub 6] (27.1.3)

2 Likes

I also have this log entries since my upgrade to NC 27.1.4 - it did not occur in 27.1.3!

And I don’t have LDAP users, all users are “local” to my NC instance - so the error is not related to LDAP…

The exact error message in my case is:
OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3285472-1700303573' for key 'files_versions_uniq_index'

I also see this in NC 28.0.1 (release) on all instances that use GroupFolders. Error log says (every ~67 minutes):

DbalException An exception occurred while executing a query:
  SQLSTATE[23000]: Integrity constraint violation:
  1062 Duplicate entry 'SOME-NUMBERNNNN'
  for key 'gf_versions_uniq_index'
Error while running background job
  (class: OCA\GroupFolders\BackgroundJob\ExpireGroupVersions,
  arguments: )

I (probably temporarily) ‘solved’ it by deleting the trashbins of all users:

sudo 33 php /PATH/occ trashbin:cleanup --all-users

See Backends provided no user object · Issue #2559 · nextcloud/groupfolders · GitHub