server icon indicating copy to clipboard operation
server copied to clipboard

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

Open tcitworld opened this issue 2 years ago • 1 comments

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 avatar Mar 10 '23 10:03 tcitworld

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

tcitworld avatar Mar 10 '23 11:03 tcitworld