diff options
| author | Moisés López <moylop260@vauxoo.com> | 2020-07-08 16:52:53 +0000 |
|---|---|---|
| committer | Moisés López <moylop260@vauxoo.com> | 2020-09-14 13:14:03 +0000 |
| commit | 35d1c5d16ccf816cbf582245047ca853d7e66d59 (patch) | |
| tree | 69d9febe0ff902ffa93a30e943fb9b49a3da9c92 /addons | |
| parent | 9c642160d46101f9e83dd80750db1df9b11997d8 (diff) | |
[FIX] base_import: mitigate concurrent update errors
Column mappings are updated in-place, if multiple users are importing records
of the same model at the same time, this will trigger concurrency errors.
This is made worse by the error only being reported on commit (after having
processed the entire import) and being retried automatically, so it slows down
the user and the entire system, the more concurrent imports the slower.
Log except:
INFO dbname odoo.addons.base_import.models.base_import: done
ERROR dbname odoo.sql_db: bad query: UPDATE "base_import_mapping" SET "field_name"='name',"write_uid"=%s,"write_date"=(now() at time zone 'UTC') WHERE id IN (%s)
ERROR: could not serialize access due to concurrent update
INFO dbname odoo.service.model: SERIALIZATION_FAILURE, retry 1/5 in 0.8720 sec...
closes odoo/odoo#57653
X-original-commit: 3f5e9ca625b53021c100245f5786bda4069974ad
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/base_import/models/base_import.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index ce943858431..2642127454a 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -951,9 +951,11 @@ class Import(models.TransientModel): for index, column_name in enumerate(columns): if column_name: # Update to latest selected field - exist_records = BaseImportMapping.search([('res_model', '=', self.res_model), ('column_name', '=', column_name)]) - if exist_records: - exist_records.write({'field_name': fields[index]}) + mapping_domain = [('res_model', '=', self.res_model), ('column_name', '=', column_name)] + column_mapping = BaseImportMapping.search(mapping_domain, limit=1) + if column_mapping: + if column_mapping.field_name != fields[index]: + column_mapping.field_name = fields[index] else: BaseImportMapping.create({ 'res_model': self.res_model, |
