From dc8aecbee2f6c39ec8d48f9246fa855142cb5beb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 10 Mar 2023 11:56:27 +0100 Subject: [PATCH] fix(profile): Set profile config cache directly after writing it to DB 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 --- lib/private/Profile/ProfileManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/Profile/ProfileManager.php b/lib/private/Profile/ProfileManager.php index c8fb780bbe892..84567f8516aa1 100644 --- a/lib/private/Profile/ProfileManager.php +++ b/lib/private/Profile/ProfileManager.php @@ -347,6 +347,7 @@ public function getProfileConfig(IUser $targetUser, ?IUser $visitingUser): array $this->filterNotStoredProfileConfig($config->getConfigArray()), )); $this->configMapper->update($config); + $this->configCache[$targetUser->getUID()] = $config; $configArray = $config->getConfigArray(); } catch (DoesNotExistException $e) { // Create a new default config if it does not exist @@ -354,6 +355,7 @@ public function getProfileConfig(IUser $targetUser, ?IUser $visitingUser): array $config->setUserId($targetUser->getUID()); $config->setConfigArray($defaultProfileConfig); $this->configMapper->insert($config); + $this->configCache[$targetUser->getUID()] = $config; $configArray = $config->getConfigArray(); }