From f3bb9ae679c665b4747ed9f52d47015a5d87f120 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 13 Dec 2017 15:04:28 +0100 Subject: [PATCH] [FIX] unnecessary rebuilding of assets The checksum computed to verify the version of the assets includes a list of files as JSON. This JSON is generated from a list of dictionaries. When using Python <3.6, the ordering of the dictionaries is not guaranteed which lead to unnecessary rebuild of assets. Particularly when starting Odoo on more than one host, the current implementation hits this issue: * server 1 computes the checksum with an ordering and generates the assets * server 2 computes the checksum with a different ordering and generates the assets * server 1 computes the checksum with a different ordering and generates the assets * And so on... Which obviously lead to disastrous performances. --- odoo/addons/base/ir/ir_qweb/assetsbundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_qweb/assetsbundle.py b/odoo/addons/base/ir/ir_qweb/assetsbundle.py index 9137e10212a..9c3b694a068 100644 --- a/odoo/addons/base/ir/ir_qweb/assetsbundle.py +++ b/odoo/addons/base/ir/ir_qweb/assetsbundle.py @@ -152,7 +152,7 @@ class AssetsBundle(object): Not really a full checksum. We compute a SHA1 on the rendered bundle + max linked files last_modified date """ - check = u"%s%s%s" % (json.dumps(self.files), u",".join(self.remains), self.last_modified) + check = u"%s%s%s" % (json.dumps(self.files, sort_keys=True), u",".join(self.remains), self.last_modified) return hashlib.sha1(check.encode('utf-8')).hexdigest() def clean_attachments(self, type):