]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add threading lock for SqliteStore
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Mon, 10 Feb 2025 15:20:02 +0000 (16:20 +0100)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Mon, 10 Feb 2025 15:20:54 +0000 (16:20 +0100)
Fixes: https://tracker.ceph.com/issues/69886
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
src/pybind/mgr/smb/sqlite_store.py

index 23efbd894ca121ce2ac1139a7a8c21277596c9a7..6b394e50ea380a7fc41ec68f45f5bf66c257b4f6 100644 (file)
@@ -21,6 +21,7 @@ import contextlib
 import copy
 import json
 import logging
+import threading
 
 from .config_store import ObjectCachingEntry
 from .proto import (
@@ -257,6 +258,7 @@ class SqliteStore:
         self._tables: Dict[str, Table] = {t.namespace: t for t in tables}
         self._prepared = False
         self._cursor: Optional[Cursor] = None
+        self._db_lock = threading.Lock()
 
     def _prepare_tables(self) -> None:
         """Automatic/internal table preparation."""
@@ -281,7 +283,7 @@ class SqliteStore:
     @contextlib.contextmanager
     def transaction(self) -> Iterator[None]:
         """Explicitly start a DB transaction."""
-        with self._db():
+        with self._db_lock, self._db():
             assert self._cursor
             self._cursor.execute('BEGIN;')
             yield None