diff options
author | Chris Laplante <chris.laplante@agilent.com> | 2020-01-16 11:28:05 -0500 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2020-02-08 13:25:27 -0800 |
commit | 2ba2f224b50956313f5c2ba01942143b4d6098f2 (patch) | |
tree | 6222c48272a1ed52501c1797d04f7a1bfd627c73 | |
parent | 716cdf737bc536f84ed1254d464c9f286e0d5a9a (diff) | |
download | bitbake-2ba2f224b50956313f5c2ba01942143b4d6098f2.tar.gz |
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.
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit feb43e7c30f5bfab75d718896c45df621810d06f)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | lib/bb/persist_data.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py index de8f87a8b..7357ab2d4 100644 --- a/lib/bb/persist_data.py +++ b/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: |