diff options
author | stephan <stephan@noemail.net> | 2022-12-02 18:06:26 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-12-02 18:06:26 +0000 |
commit | 95bc4d67bbc8abe0783605e5f98dc1689d213352 (patch) | |
tree | dda7cd1409285f3de78c3b089dd40e3cdb0ec25a /ext/wasm/api/sqlite3-opfs-async-proxy.js | |
parent | d2603adf46aee6e5e7d3ad963e1947e69d617b58 (diff) | |
download | sqlite-95bc4d67bbc8abe0783605e5f98dc1689d213352.tar.gz sqlite-95bc4d67bbc8abe0783605e5f98dc1689d213352.zip |
OPFS VFS: translate createSyncAccessHandle() exceptions which appear to be locking violations to SQLITE_BUSY. This seems to improve concurrency considerably even with a reduced retry count of 5 (was 6).
FossilOrigin-Name: 0d36021d107d3afca190ad61c3380536ad0cc2d493d345d48f9f9c1191741128
Diffstat (limited to 'ext/wasm/api/sqlite3-opfs-async-proxy.js')
-rw-r--r-- | ext/wasm/api/sqlite3-opfs-async-proxy.js | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index d8234d509..e77ff7809 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -263,21 +263,18 @@ const installAsyncProxy = function(self){ } }; GetSyncHandleError.convertRc = (e,rc)=>{ - if(0){ - /* This approach makes the very wild assumption that such a - failure _is_ a locking error. In practice that appears to be - the most common error, by far, but we cannot unambiguously - distinguish that from other errors. - - This approach is highly questionable. - - Note that even if we return SQLITE_IOERR_LOCK from here, - it bubbles up to the client as a plain I/O error. - */ - return (e instanceof GetSyncHandleError - && e.cause.name==='NoModificationAllowedError') - ? state.sq3Codes.SQLITE_IOERR_LOCK - : rc; + if(1){ + return ( + e instanceof GetSyncHandleError + && ((e.cause.name==='NoModificationAllowedError') + /* Inconsistent exception.name from Chrome/ium with the + same exception.message text: */ + || (e.cause.name==='DOMException' + && 0===e.cause.message.indexOf('Access Handles cannot'))) + ) ? ( + /*console.warn("SQLITE_BUSY",e),*/ + state.sq3Codes.SQLITE_BUSY + ) : rc; }else{ return rc; } @@ -298,7 +295,7 @@ const installAsyncProxy = function(self){ if(!fh.syncHandle){ const t = performance.now(); log("Acquiring sync handle for",fh.filenameAbs); - const maxTries = 6, msBase = state.asyncIdleWaitTime * 3; + const maxTries = 5, msBase = state.asyncIdleWaitTime * 2; let i = 1, ms = msBase; for(; true; ms = msBase * ++i){ try { |