Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(profile): Set profile config cache directly after writing it to DB #37170

Closed
wants to merge 1 commit into from

Conversation

tcitworld
Copy link
Member

@tcitworld tcitworld commented Mar 10, 2023

In ProfileManager::getProfileParams we make a lot of indirect calls to ProfileManager::getProfileConfig. The first time we get the call we get into the catch and insert data, and the next time we miss the cache and do the select. There's a possibility of read-after-write issue here (the database r/o-mirror doesn't have the inserted config yet), which leads to conflicts when it tries to reinsert the config. To avoid that, let's put the config value in the configcache directly when it's written.

Fixes:

OC\DB\Exceptions\DbalException

An exception occurred while executing a query: SQLSTATE[23505]: Unique violation: 7 ERREUR:  la valeur d'une clé dupliquée rompt la contrainte unique « profile_config_user_id_idx »
DETAIL:  La clé « (user_id)=(Directrice) » existe déjà.

Checklist

@tcitworld tcitworld added bug 3. to review Waiting for reviews feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) labels Mar 10, 2023
@tcitworld tcitworld requested review from nickvergessen, Pytal and a team March 10, 2023 10:57
@tcitworld tcitworld self-assigned this Mar 10, 2023
@tcitworld tcitworld requested review from ArtificialOwl, icewind1991 and blizzz and removed request for a team March 10, 2023 10:57
@tcitworld
Copy link
Member Author

This makes AccountMigrator tests unhappy for some reason. If you know why @Pytal

@@ -385,13 +385,15 @@ public function getProfileConfig(IUser $targetUser, ?IUser $visitingUser): array
$this->filterNotStoredProfileConfig($config->getConfigArray()),
));
$this->configMapper->update($config);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: BTW, do we really need to update the config at each call? Can't we just check if the merged config has been updated and only update it in this case?

@blizzz blizzz added this to the Nextcloud 29 milestone Nov 23, 2023
@tcitworld tcitworld force-pushed the fix/profile/set-config-cache-after-write branch from 1361e88 to ac9a2e4 Compare February 1, 2024 17:39
In ProfileManager::getProfileParams we make a lot of indirect calls to ProfileManager::getProfileConfig. The first time we get the call we get into the catch and insert data, and the next time we miss the cache and do the select. There's a possibility of read-after-write issue here (the database r/o-mirror doesn't have yet the inserted config), which leads to conflicts when it tries to reinsert the config. To avoid that, let's put the config value in the configcache directly when it's written.

Signed-off-by: Thomas Citharel <[email protected]>
@AndyScherzinger AndyScherzinger force-pushed the fix/profile/set-config-cache-after-write branch from ac9a2e4 to dc8aecb Compare February 27, 2024 13:19
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
@skjnldsv skjnldsv added 2. developing Work in progress stale Ticket or PR with no recent activity and removed 3. to review Waiting for reviews labels Jul 27, 2024
@blizzz blizzz mentioned this pull request Jul 30, 2024
@blizzz blizzz mentioned this pull request Aug 1, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
@tcitworld
Copy link
Member Author

I think this is fixed already

@skjnldsv skjnldsv deleted the fix/profile/set-config-cache-after-write branch September 11, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress bug feature: profile PRs or issues related to the Profile feature (e.g. Profile page, API, etc.) stale Ticket or PR with no recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants