From 64d62e5d48014af963967e4b5b24553853cb6df3 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Thu, 16 Jan 2020 11:28:05 -0500 Subject: bitbake: persist_data.py: Immediately get exclusive lock in __setitem__ To avoid races, SQLTable::__setitem__ needs an exclusive lock for the entire transaction, not just the INSERT/UPDATE part. (Bitbake rev: 2ba2f224b50956313f5c2ba01942143b4d6098f2) Signed-off-by: Chris Laplante Signed-off-by: Richard Purdie (cherry picked from commit feb43e7c30f5bfab75d718896c45df621810d06f) Signed-off-by: Armin Kuster Signed-off-by: Richard Purdie --- bitbake/lib/bb/persist_data.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bitbake') diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py index de8f87a8bf..7357ab2d44 100644 --- a/bitbake/lib/bb/persist_data.py +++ b/bitbake/lib/bb/persist_data.py @@ -179,6 +179,9 @@ class SQLTable(collections.MutableMapping): elif not isinstance(value, str): raise TypeError('Only string values are supported') + # Ensure the entire transaction (including SELECT) executes under write lock + cursor.execute("BEGIN EXCLUSIVE") + cursor.execute("SELECT * from %s where key=?;" % self.table, [key]) row = cursor.fetchone() if row is not None: -- cgit v1.2.3-54-g00ecf