From 289d6045a9491e684e643505a2db6c87a156e62c Mon Sep 17 00:00:00 2001 From: Pedro Gonzalez Gomez Date: Mon, 10 Feb 2025 16:20:02 +0100 Subject: [PATCH] mgr/smb: add threading lock for SqliteStore Fixes: https://tracker.ceph.com/issues/69886 Signed-off-by: Pedro Gonzalez Gomez --- src/pybind/mgr/smb/sqlite_store.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.39.5