[FIX] server.py: cron trigger in recovery
When setting up the PG replication, the slave is considered in recovery mode. However, `LISTEN / NOTIFY` is not supported in this mode, leading to an endless loop of crashes. In recovery mode, we simply deactivate the feature. closes odoo/odoo#87619 X-original-commit: 6389a64953081130d62f2a1703a27ddfa751098b Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
+14
-2
@@ -430,7 +430,13 @@ class ThreadedServer(CommonServer):
|
||||
conn = odoo.sql_db.db_connect('postgres')
|
||||
with conn.cursor() as cr:
|
||||
pg_conn = cr._cnx
|
||||
cr.execute("LISTEN cron_trigger")
|
||||
# LISTEN / NOTIFY doesn't work in recovery mode
|
||||
cr.execute("SELECT pg_is_in_recovery()")
|
||||
in_recovery = cr.fetchone()[0]
|
||||
if not in_recovery:
|
||||
cr.execute("LISTEN cron_trigger")
|
||||
else:
|
||||
_logger.warning("PG cluster in recovery mode, cron trigger not activated")
|
||||
cr.commit()
|
||||
|
||||
while True:
|
||||
@@ -1162,7 +1168,13 @@ class WorkerCron(Worker):
|
||||
|
||||
dbconn = odoo.sql_db.db_connect('postgres')
|
||||
self.dbcursor = dbconn.cursor()
|
||||
self.dbcursor.execute("LISTEN cron_trigger")
|
||||
# LISTEN / NOTIFY doesn't work in recovery mode
|
||||
self.dbcursor.execute("SELECT pg_is_in_recovery()")
|
||||
in_recovery = self.dbcursor.fetchone()[0]
|
||||
if not in_recovery:
|
||||
self.dbcursor.execute("LISTEN cron_trigger")
|
||||
else:
|
||||
_logger.warning("PG cluster in recovery mode, cron trigger not activated")
|
||||
self.dbcursor.commit()
|
||||
|
||||
def stop(self):
|
||||
|
||||
Reference in New Issue
Block a user