Skip to content

Commit

Permalink
fix(profile): Set profile config cache directly after writing it to DB
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tcitworld committed Feb 1, 2024
1 parent 937a6a8 commit ac9a2e4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/private/Profile/ProfileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,15 @@ 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
$config = new ProfileConfig();
$config->setUserId($targetUser->getUID());
$config->setConfigArray($defaultProfileConfig);
$this->configMapper->insert($config);
$this->configCache[$targetUser->getUID()] = $config;
$configArray = $config->getConfigArray();
}

Expand Down

0 comments on commit ac9a2e4

Please sign in to comment.