Closed Ricardoalso closed 1 month ago
/ocabot merge patch
This PR looks fantastic, let's merge it! Prepared branch 14.0-ocabot-merge-pr-642-by-thomaspaulb-bump-patch, awaiting test results.
Congratulations, your PR was merged at bb9e38878b7e4df780d67e388bd44db45088c398. Thanks a lot for contributing to OCA. ❤️
Code before the PR
This line of code locks the records of the SAML providers specified in providers.ids to avoid concurrent update conflicts. The locking is performed at the database level using the FOR UPDATE clause in the SQL query.
After the lock query, a loop is performed over each locked SAML provider.
for provider in providers:
The provider's metadata is downloaded from the provider.idp_metadata_url. If the download fails (status code different from 200), an error is raised.
If the content of the downloaded metadata (document.text) is different from the current provider's metadata (provider.idp_metadata), the metadata is updated with the new content. A log message is also recorded to indicate that the metadata has been updated.
Identified Problem The raised problem is that, although the code locks the provider records, it does not commit the changes made to the records that were not updated (those that fall into the else). This means that the locking is not released for these records, which can potentially lead to performance issues or locks waiting forever.
Improvement Suggestion To resolve this issue, we only lock records matching document.text != provider.idp_metadata