[FIX] event: fix savepoint issue with event mail scheduler

This commit removes a savepoint call when running the event mail scheduler.

Indeed, this save point registration was colliding with the fact that we commit
the assets bundle during the reporting process, see 'commit_assetsbundle'
context key.

Since the transaction was commit during the report generation, when reaching
the end of the savepoint block, the system was trying to release a savepoint
that was no longer existing.

Indeed, committing removes all savepoints, since (quoting the Postgres doc)
"Savepoints can only be established when inside a transaction block.", which
makes total sense.

This was leading to a:
bad query: RELEASE SAVEPOINT "669516d2915811eba8d2b4d5bde7cdcc"
Aborting the whole event mail scheduler process.

As it's rather unclear why this savepoint was introduced in the first place,
we attempt to remove it. This change is done in a singular commit to be easily
revertable if ever necessary.

Task-26779
This commit is contained in:
Aurélien Warnon
2021-07-30 09:02:54 +00:00
parent 44b55dc883
commit 8bae36bc1a
+2 -3
View File
@@ -235,9 +235,8 @@ You receive this email because you are:
for scheduler in schedulers:
try:
with self.env.cr.savepoint():
# Prevent a mega prefetch of the registration ids of all the events of all the schedulers
self.browse(scheduler.id).execute()
# Prevent a mega prefetch of the registration ids of all the events of all the schedulers
self.browse(scheduler.id).execute()
except Exception as e:
_logger.exception(e)
self.invalidate_cache()