Skip to content

Commit 289d604

Browse files
committed
mgr/smb: add threading lock for SqliteStore
Fixes: https://tracker.ceph.com/issues/69886 Signed-off-by: Pedro Gonzalez Gomez <[email protected]>
1 parent 580ff0a commit 289d604

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pybind/mgr/smb/sqlite_store.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import copy
2222
import json
2323
import logging
24+
import threading
2425

2526
from .config_store import ObjectCachingEntry
2627
from .proto import (
@@ -257,6 +258,7 @@ def __init__(self, backend: DBAcessor, tables: Iterable[Table]) -> None:
257258
self._tables: Dict[str, Table] = {t.namespace: t for t in tables}
258259
self._prepared = False
259260
self._cursor: Optional[Cursor] = None
261+
self._db_lock = threading.Lock()
260262

261263
def _prepare_tables(self) -> None:
262264
"""Automatic/internal table preparation."""
@@ -281,7 +283,7 @@ def _table(self, key: Union[str, EntryKey]) -> Table:
281283
@contextlib.contextmanager
282284
def transaction(self) -> Iterator[None]:
283285
"""Explicitly start a DB transaction."""
284-
with self._db():
286+
with self._db_lock, self._db():
285287
assert self._cursor
286288
self._cursor.execute('BEGIN;')
287289
yield None

0 commit comments

Comments
 (0)