fix blob manager db race condition
This commit is contained in:
parent
5679ffb6a9
commit
82118e6692
2 changed files with 3 additions and 4 deletions
|
@ -17,7 +17,7 @@ at anytime.
|
||||||
*
|
*
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
*
|
* Race condition from improper initialization and shutdown of the blob manager database
|
||||||
*
|
*
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
@ -83,7 +83,7 @@ class DiskBlobManager(BlobManager):
|
||||||
BlobManager.__init__(self, hash_announcer)
|
BlobManager.__init__(self, hash_announcer)
|
||||||
self.blob_dir = blob_dir
|
self.blob_dir = blob_dir
|
||||||
self.db_file = os.path.join(db_dir, "blobs.db")
|
self.db_file = os.path.join(db_dir, "blobs.db")
|
||||||
self.db_conn = None
|
self.db_conn = adbapi.ConnectionPool('sqlite3', self.db_file, check_same_thread=False)
|
||||||
self.blob_type = BlobFile
|
self.blob_type = BlobFile
|
||||||
self.blob_creator_type = BlobFileCreator
|
self.blob_creator_type = BlobFileCreator
|
||||||
# TODO: consider using an LRU for blobs as there could potentially
|
# TODO: consider using an LRU for blobs as there could potentially
|
||||||
|
@ -104,7 +104,7 @@ class DiskBlobManager(BlobManager):
|
||||||
if self._next_manage_call is not None and self._next_manage_call.active():
|
if self._next_manage_call is not None and self._next_manage_call.active():
|
||||||
self._next_manage_call.cancel()
|
self._next_manage_call.cancel()
|
||||||
self._next_manage_call = None
|
self._next_manage_call = None
|
||||||
self.db_conn = None
|
self.db_conn.close()
|
||||||
return defer.succeed(True)
|
return defer.succeed(True)
|
||||||
|
|
||||||
def get_blob(self, blob_hash, length=None):
|
def get_blob(self, blob_hash, length=None):
|
||||||
|
@ -233,7 +233,6 @@ class DiskBlobManager(BlobManager):
|
||||||
# to a bug in twisted, where the connection is closed by a different thread than the
|
# to a bug in twisted, where the connection is closed by a different thread than the
|
||||||
# one that opened it. The individual connections in the pool are not used in multiple
|
# one that opened it. The individual connections in the pool are not used in multiple
|
||||||
# threads.
|
# threads.
|
||||||
self.db_conn = adbapi.ConnectionPool('sqlite3', self.db_file, check_same_thread=False)
|
|
||||||
|
|
||||||
def create_tables(transaction):
|
def create_tables(transaction):
|
||||||
transaction.execute("create table if not exists blobs (" +
|
transaction.execute("create table if not exists blobs (" +
|
||||||
|
|
Loading…
Reference in a new issue