mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[FIX] runbot: warn when a local pg backend cannot be terminated
For whatever reason, it happens that we open a testing database in a psql console as another user. In that case, the runbot is unable to terminate the backend and goes in an error loop.
This commit is contained in:
parent
f7a12c6359
commit
f03b0140d5
@ -19,6 +19,7 @@ from odoo.tools.safe_eval import safe_eval
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from psycopg2 import sql
|
||||
from psycopg2.errors import InsufficientPrivilege
|
||||
import getpass
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@ -876,7 +877,11 @@ class BuildResult(models.Model):
|
||||
def _local_pg_dropdb(self, dbname):
|
||||
with local_pgadmin_cursor() as local_cr:
|
||||
pid_col = 'pid' if local_cr.connection.server_version >= 90200 else 'procpid'
|
||||
query = 'SELECT pg_terminate_backend({}) FROM pg_stat_activity WHERE datname=%s'.format(pid_col)
|
||||
try:
|
||||
query = 'SELECT pg_terminate_backend({}) FROM pg_stat_activity WHERE datname=%s'.format(pid_col)
|
||||
except InsufficientPrivilege:
|
||||
_logger.warning('Cannot terminate backend process for %s (maybe a root psql console is accessing the database).', dbname)
|
||||
return
|
||||
local_cr.execute(query, [dbname])
|
||||
local_cr.execute('DROP DATABASE IF EXISTS "%s"' % dbname)
|
||||
# cleanup filestore
|
||||
|
Loading…
Reference in New Issue
Block a user