Nicolas Évrard pushed to branch branch/default at Tryton / Tryton


Commits:
48396d9c by Nicolas Évrard at 2023-07-14T18:50:44+02:00
Clear caches after commit when installing modules

A call to clear_all is required after the commit in order to ensure that the
transaction uses an empty cache from this point. clear_all is not required to
prevent the deadlock on ir.cache because the rollback ensures that nothing
changed from the point of view of this transaction.

Close #12343
- - - - -


1 changed file:

- trytond/trytond/modules/__init__.py


Changes:

=====================================
trytond/trytond/modules/__init__.py
=====================================
@@ -274,8 +274,6 @@
                                 ]))
                 module2state[module] = 'activated'
 
-            # Clear cache from old data cached before transaction started
-            Cache.clear_all()
-            # Avoid clearing cache to prevent dead lock on ir.cache table
+            # Rollback cache changes to prevent dead lock on ir.cache table
             Cache.rollback(transaction)
             transaction.commit()
@@ -280,5 +278,10 @@
             Cache.rollback(transaction)
             transaction.commit()
+            # Clear the cache so that the transaction has an empty cache
+            # from now on. The cache is not empty because the rollback might
+            # have filled it with old data from before the transaction
+            # started.
+            Cache.clear_all()
             # Clear transaction cache to update default_factory
             transaction.cache.clear()
 



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/48396d9cfed6caccb3fca6d981fec5016a1f6ca2

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/48396d9cfed6caccb3fca6d981fec5016a1f6ca2
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to