Skip to Content
Menu
This question has been flagged
1 Reply
2825 Views

2022-01-21 14:43:54,845 2599 ERROR goldenvapekw-main-3775372 odoo.sql_db: bad query: update ir_module_module set demo=false where id=30
ERROR: deadlock detected
DETAIL: Process 2569614 waits for ShareLock on transaction 140263422; blocked by process 2589138.
Process 2589138 waits for ShareLock on transaction 140263417; blocked by process 2569614.
HINT: See server log for query details.
CONTEXT: while updating tuple (64,8) in relation "ir_module_module"

2022-01-21 14:43:54,849 2599 ERROR goldenvapekw-main-3775372 odoo.sql_db: bad query: UPDATE ir_module_module SET state='installed' WHERE state IN ('to remove', 'to upgrade')
ERROR: could not serialize access due to concurrent update

2022-01-21 14:43:54,850 2599 ERROR goldenvapekw-main-3775372 odoo.modules.registry: Failed to load registry
2022-01-21 14:43:54,850 2599 CRITICAL goldenvapekw-main-3775372 odoo.service.server: Failed to initialize database `goldenvapekw-main-3775372`.
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 87, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 470, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 224, in load_module_graph
cr.execute('update ir_module_module set demo=%s where id=%s', (demo_loaded, module_id))
File "", line 2, in execute
File "/home/odoo/src/odoo/odoo/sql_db.py", line 89, in check
return f(self, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/sql_db.py", line 310, in execute
res = self._obj.execute(query, params)
psycopg2.errors.DeadlockDetected: deadlock detected
DETAIL: Process 2569614 waits for ShareLock on transaction 140263422; blocked by process 2589138.
Process 2589138 waits for ShareLock on transaction 140263417; blocked by process 2569614.
HINT: See server log for query details.
CONTEXT: while updating tuple (64,8) in relation "ir_module_module"


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/service/server.py", line 1246, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/home/odoo/src/odoo/odoo/modules/registry.py", line 89, in new
odoo.modules.reset_modules_state(db_name)
File "/home/odoo/src/odoo/odoo/modules/loading.py", line 599, in reset_modules_state
cr.execute(
File "", line 2, in execute
File "/home/odoo/src/odoo/odoo/sql_db.py", line 89, in check
return f(self, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/sql_db.py", line 310, in execute
res = self._obj.execute(query, params)
psycopg2.errors.SerializationFailure: could not serialize access due to concurrent update

Avatar
Discard
Best Answer

The error message "psycopg2.errors.SerializationFailure: could not serialize access due to concurrent update" is a PostgreSQL error that occurs when two or more transactions try to access the same data at the same time and conflict with each other. This can happen when multiple users are trying to update the same record in the database simultaneously.

To resolve this error, you can use a transaction isolation level that supports serializable transactions. This will allow the database to detect conflicts and prevent concurrent updates that could cause the error.

You can also use a technique called "Optimistic Locking" which uses a version number for the records and it will check if the record has been modified after you fetch it and before you want to update it. If it has been modified it will throw an exception and you can decide to retry or notify the user that the record has been modified by someone else.

Additionally, you can use a technique called "Pessimistic Locking" which will lock the record while you are working on it, this way other users will not be able to access it until you finish. But this will cause delays and is less recommended.

In Odoo, you can use the '@api.constrains' decorator in your class that you want to validate to check for concurrent access and handle it. This will be used for validation and will raise an exception if a constraint is not satisfied.

Avatar
Discard
Related Posts Replies Views Activity
3
Jan 18
7155