[oe-commits] [bitbake] 07/07: persist_data.py: Immediately get exclusive lock in __setitem__

git at git.openembedded.org git at git.openembedded.org
Sun Jan 19 13:32:57 UTC 2020


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository bitbake.

commit feb43e7c30f5bfab75d718896c45df621810d06f
Author: Chris Laplante <chris.laplante at agilent.com>
AuthorDate: Thu Jan 16 11:28:05 2020 -0500

    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 at agilent.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/persist_data.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py
index de8f87a..7357ab2 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:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list