nextcloud / nextcloud/server

Profile config creation is not made in a transaction

Open
#35,774 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop feature: profile technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.
Bug description

I'm putting logs here to investigate later how this can be handled properly. Will probably need a transaction for the whole function.

"{\"Exception\":\"OC\\\\DB\\\\Exceptions\\\\DbalException\",\"Message\":\"An exception occurred while executing a query: SQLSTATE[23505]: Unique violation: 7 ERREUR:  la valeur d'une cl\\u00e9 dupliqu\\u00e9e rompt la contrainte unique \\u00ab profile_config_user_id_idx \\u00bb\\nDETAIL:  La cl\\u00e9 \\u00ab (user_id)=(raja white) \\u00bb existe d\\u00e9j\\u00e0.\",\"Code\":7,\"Trace\":[{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/QueryBuilder/QueryBuilder.php\",\"line\":329,\"function\":\"wrap\",\"class\":\"OC\\\\DB\\\\Exceptions\\\\DbalException\",\"type\":\"::\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/public/AppFramework/Db/QBMapper.php\",\"line\":139,\"function\":\"executeStatement\",\"class\":\"OC\\\\DB\\\\QueryBuilder\\\\QueryBuilder\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":393,\"function\":\"insert\",\"class\":\"OCP\\\\AppFramework\\\\Db\\\\QBMapper\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":239,\"function\":\"getProfileConfig\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":306,\"function\":\"isParameterVisible\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/core/Controller/ProfilePageController.php\",\"line\":116,\"function\":\"getProfileParams\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":225,\"function\":\"index\",\"class\":\"OC\\\\Core\\\\Controller\\\\ProfilePageController\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":133,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/App.php\",\"line\":172,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Route/Router.php\",\"line\":298,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/base.php\",\"line\":1047,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/index.php\",\"line\":36,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\"}],\"File\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/Exceptions/DbalException.php\",\"Line\":71,\"Previous\":{\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\UniqueConstraintViolationException\",\"Message\":\"An exception occurred while executing a query: SQLSTATE[23505]: Unique violation: 7 ERREUR:  la valeur d'une cl\\u00e9 dupliqu\\u00e9e rompt la contrainte unique \\u00ab profile_config_user_id_idx \\u00bb\\nDETAIL:  La cl\\u00e9 \\u00ab (user_id)=(raja white) \\u00bb existe d\\u00e9j\\u00e0.\",\"Code\":7,\"Trace\":[{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Connection.php\",\"line\":1780,\"function\":\"convert\",\"class\":\"Doctrine\\\\DBAL\\\\Driver\\\\API\\\\PostgreSQL\\\\ExceptionConverter\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Connection.php\",\"line\":1719,\"function\":\"handleDriverException\",\"class\":\"Doctrine\\\\DBAL\\\\Connection\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Connection.php\",\"line\":1173,\"function\":\"convertExceptionDuringQuery\",\"class\":\"Doctrine\\\\DBAL\\\\Connection\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/Connection.php\",\"line\":294,\"function\":\"executeStatement\",\"class\":\"Doctrine\\\\DBAL\\\\Connection\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php\",\"line\":354,\"function\":\"executeStatement\",\"class\":\"OC\\\\DB\\\\Connection\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/QueryBuilder/QueryBuilder.php\",\"line\":281,\"function\":\"execute\",\"class\":\"Doctrine\\\\DBAL\\\\Query\\\\QueryBuilder\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/QueryBuilder/QueryBuilder.php\",\"line\":327,\"function\":\"execute\",\"class\":\"OC\\\\DB\\\\QueryBuilder\\\\QueryBuilder\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/public/AppFramework/Db/QBMapper.php\",\"line\":139,\"function\":\"executeStatement\",\"class\":\"OC\\\\DB\\\\QueryBuilder\\\\QueryBuilder\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":393,\"function\":\"insert\",\"class\":\"OCP\\\\AppFramework\\\\Db\\\\QBMapper\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":239,\"function\":\"getProfileConfig\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Profile/ProfileManager.php\",\"line\":306,\"function\":\"isParameterVisible\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/core/Controller/ProfilePageController.php\",\"line\":116,\"function\":\"getProfileParams\",\"class\":\"OC\\\\Profile\\\\ProfileManager\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":225,\"function\":\"index\",\"class\":\"OC\\\\Core\\\\Controller\\\\ProfilePageController\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":133,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/AppFramework/App.php\",\"line\":172,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/Route/Router.php\",\"line\":298,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/base.php\",\"line\":1047,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/index.php\",\"line\":36,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\"}],\"File\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php\",\"Line\":55,\"Previous\":{\"Exception\":\"Doctrine\\\\DBAL\\\\Driver\\\\PDO\\\\Exception\",\"Message\":\"SQLSTATE[23505]: Unique violation: 7 ERREUR:  la valeur d'une cl\\u00e9 dupliqu\\u00e9e rompt la contrainte unique \\u00ab profile_config_user_id_idx \\u00bb\\nDETAIL:  La cl\\u00e9 \\u00ab (user_id)=(raja white) \\u00bb existe d\\u00e9j\\u00e0.\",\"Code\":7,\"Trace\":[{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php\",\"line\":94,\"function\":\"new\",\"class\":\"Doctrine\\\\DBAL\\\\Driver\\\\PDO\\\\Exception\",\"type\":\"::\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Connection.php\",\"line\":1163,\"function\":\"execute\",\"class\":\"Doctrine\\\\DBAL\\\\Driver\\\\PDO\\\\Statement\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/lib/private/DB/Connection.php\",\"line\":294,\"function\":\"executeStatement\",\"class\":\"Doctrine\\\\DBAL\\\\Connection\",\"type\":\"->\"},{\"file\":\"/var/www/nc/nextcloud-25.0.1/3rdparty/doctrine/dbal/src/Query/Qu
Steps to reproduce

n/a

Expected behavior

n/a

Installation method

None

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Nginx

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

No response

List of activated Apps
n/a
Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/private/Profile/ProfileManager.php, especially getProfileConfig around lines 239 and 393, and trace how profile configuration creation reaches the database insert. Determine the transaction boundary needed for the whole function and verify that repeated profile access no longer produces the reported PostgreSQL unique-constraint failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.