mirror of
https://github.com/zotero/zotero.git
synced 2026-08-28 05:25:31 +00:00
Open the database only once when callers arrive concurrently
_getConnectionAsync() checked for an existing connection and then awaited several filesystem operations before assigning one, so callers arriving in that window each opened their own. Only the last was kept, and the rest stayed open and unreachable, holding a mozStorage thread apiece until shutdown.
This commit is contained in:
parent
9e45191b22
commit
e8055dfdf2
1 changed files with 12 additions and 0 deletions
|
|
@ -1548,6 +1548,18 @@ Zotero.DBConnection.prototype._getConnectionAsync = async function () {
|
||||||
throw new Error("Database permanently closed; not re-opening");
|
throw new Error("Database permanently closed; not re-opening");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Opening is asynchronous, so callers arriving while it's under way share the same attempt
|
||||||
|
if (!this._openPromise) {
|
||||||
|
this._openPromise = this._openConnectionAsync()
|
||||||
|
.finally(() => {
|
||||||
|
this._openPromise = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this._openPromise;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.DBConnection.prototype._openConnectionAsync = async function () {
|
||||||
this._debug("Asynchronously opening database '" + this._dbName + "'");
|
this._debug("Asynchronously opening database '" + this._dbName + "'");
|
||||||
Zotero.debug(this._dbPath);
|
Zotero.debug(this._dbPath);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue