[MERGE] forward port branch saas-14 up to a7ad19d7fd
This commit is contained in:
@@ -34,4 +34,10 @@ class IrLogging(models.Model):
|
|||||||
@api.model_cr
|
@api.model_cr
|
||||||
def init(self):
|
def init(self):
|
||||||
super(IrLogging, self).init()
|
super(IrLogging, self).init()
|
||||||
self._cr.execute("ALTER TABLE ir_logging DROP CONSTRAINT IF EXISTS ir_logging_write_uid_fkey")
|
self._cr.execute("select 1 from information_schema.constraint_column_usage where table_name = 'ir_logging' and constraint_name = 'ir_logging_write_uid_fkey'")
|
||||||
|
if self._cr.rowcount:
|
||||||
|
# DROP CONSTRAINT unconditionally takes an ACCESS EXCLUSIVE lock
|
||||||
|
# on the table, even "IF EXISTS" is set and not matching; disabling
|
||||||
|
# the relevant trigger instead acquires SHARE ROW EXCLUSIVE, which
|
||||||
|
# still conflicts with the ROW EXCLUSIVE needed for an insert
|
||||||
|
self._cr.execute("ALTER TABLE ir_logging DROP CONSTRAINT ir_logging_write_uid_fkey")
|
||||||
|
|||||||
+3
-2
@@ -48,7 +48,7 @@ def LocalService(name):
|
|||||||
path_prefix = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
|
path_prefix = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
|
||||||
class PostgreSQLHandler(logging.Handler):
|
class PostgreSQLHandler(logging.Handler):
|
||||||
""" PostgreSQL Loggin Handler will store logs in the database, by default
|
""" PostgreSQL Logging Handler will store logs in the database, by default
|
||||||
the current database, can be set using --log-db=DBNAME
|
the current database, can be set using --log-db=DBNAME
|
||||||
"""
|
"""
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
@@ -58,7 +58,8 @@ class PostgreSQLHandler(logging.Handler):
|
|||||||
if not dbname:
|
if not dbname:
|
||||||
return
|
return
|
||||||
with tools.ignore(Exception), tools.mute_logger('odoo.sql_db'), sql_db.db_connect(dbname, allow_uri=True).cursor() as cr:
|
with tools.ignore(Exception), tools.mute_logger('odoo.sql_db'), sql_db.db_connect(dbname, allow_uri=True).cursor() as cr:
|
||||||
cr.autocommit(True)
|
# preclude risks of deadlocks
|
||||||
|
cr.execute("SET LOCAL statement_timeout = 1000")
|
||||||
msg = tools.ustr(record.msg)
|
msg = tools.ustr(record.msg)
|
||||||
if record.args:
|
if record.args:
|
||||||
msg = msg % record.args
|
msg = msg % record.args
|
||||||
|
|||||||
Reference in New Issue
Block a user