diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-09-11 21:24:50 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-09-11 21:24:50 -0300 |
commit | 969ab4ebeda2ac3abcb00d9beded5f013e074e4a (patch) | |
tree | 0363ee9339582ada637ae040f18b5b663b8ebc49 /src/leap/soledad/client/_db/pragmas.py | |
parent | ae11ec7d685cdf313778e0c5126ecd748608be26 (diff) |
[bug] do not allow concurrent schema creation
Moved schema creation and migrations to the pragma locked call, so we
avoid it running concurrently on a thread pool.
-- Resolves: #8945
Diffstat (limited to 'src/leap/soledad/client/_db/pragmas.py')
-rw-r--r-- | src/leap/soledad/client/_db/pragmas.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/leap/soledad/client/_db/pragmas.py b/src/leap/soledad/client/_db/pragmas.py index 870ed63e..76fea458 100644 --- a/src/leap/soledad/client/_db/pragmas.py +++ b/src/leap/soledad/client/_db/pragmas.py @@ -31,7 +31,7 @@ logger = getLogger(__name__) _db_init_lock = threading.Lock() -def set_init_pragmas(conn, opts=None, extra_queries=None): +def set_init_pragmas(conn, opts=None, extra_queries=None, schema_func=None): """ Set the initialization pragmas. @@ -43,6 +43,8 @@ def set_init_pragmas(conn, opts=None, extra_queries=None): with _db_init_lock: # only one execution path should initialize the db _set_init_pragmas(conn, opts, extra_queries) + if schema_func: + schema_func(conn) def _set_init_pragmas(conn, opts, extra_queries): |