From: Pedro Gonzalez Gomez Date: Mon, 10 Feb 2025 15:20:02 +0000 (+0100) Subject: mgr/smb: add threading lock for SqliteStore X-Git-Tag: testing/wip-pdonnell-testing-20250220.015803-debug~13^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=289d6045a9491e684e643505a2db6c87a156e62c;p=ceph-ci.git mgr/smb: add threading lock for SqliteStore Fixes: https://tracker.ceph.com/issues/69886 Signed-off-by: Pedro Gonzalez Gomez --- diff --git a/src/pybind/mgr/smb/sqlite_store.py b/src/pybind/mgr/smb/sqlite_store.py index 23efbd894ca..6b394e50ea3 100644 --- a/src/pybind/mgr/smb/sqlite_store.py +++ b/src/pybind/mgr/smb/sqlite_store.py @@ -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