From: stephan Date: Mon, 21 Nov 2022 04:12:38 +0000 (+0000) Subject: Resolve missing SQLITE_LOCKED result code which triggered a new (since last checkin... X-Git-Tag: version-3.41.0~397 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36d5554c9abaa3080e85e3b7b517605c6106587d;p=thirdparty%2Fsqlite.git Resolve missing SQLITE_LOCKED result code which triggered a new (since last checkin) exception in the OPFS VFS. Improve output of the OPFS contention tester app. FossilOrigin-Name: 2debbbca33bd4170a1dc4dbb5eb3e68523e51d289b06c551e5560ac4e32e433b --- diff --git a/ext/wasm/api/sqlite3-api-opfs.js b/ext/wasm/api/sqlite3-api-opfs.js index 1fd50dcc6f..deb4c923ab 100644 --- a/ext/wasm/api/sqlite3-api-opfs.js +++ b/ext/wasm/api/sqlite3-api-opfs.js @@ -343,6 +343,7 @@ const installOpfsVfs = function callee(options){ 'SQLITE_LOCK_PENDING', 'SQLITE_LOCK_RESERVED', 'SQLITE_LOCK_SHARED', + 'SQLITE_LOCKED', 'SQLITE_MISUSE', 'SQLITE_NOTFOUND', 'SQLITE_OPEN_CREATE', diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index 3701e8c30d..58cf8ca3c7 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -477,8 +477,8 @@ const vfsAsyncImpls = { wTimeStart('xFileSize'); try{ affirmLocked('xFileSize',fh); - rc = await (await getSyncHandle(fh)).getSize(); - state.s11n.serialize(Number(rc)); + const sz = await (await getSyncHandle(fh)).getSize(); + state.s11n.serialize(Number(sz)); rc = 0; }catch(e){ state.s11n.storeException(2,e); diff --git a/ext/wasm/tests/opfs/concurrency/test.js b/ext/wasm/tests/opfs/concurrency/test.js index d045f3271f..b80dad24c4 100644 --- a/ext/wasm/tests/opfs/concurrency/test.js +++ b/ext/wasm/tests/opfs/concurrency/test.js @@ -1,6 +1,6 @@ (async function(self){ - const logClass = (function(){ + const logCss = (function(){ const mapToString = (v)=>{ switch(typeof v){ case 'number': case 'string': case 'boolean': @@ -20,7 +20,7 @@ }; const normalizeArgs = (args)=>args.map(mapToString); const logTarget = document.querySelector('#test-output'); - const logClass = function(cssClass,...args){ + const logCss = function(cssClass,...args){ const ln = document.createElement('div'); if(cssClass){ for(const c of (Array.isArray(cssClass) ? cssClass : [cssClass])){ @@ -41,10 +41,10 @@ cbReverse.checked = !!(+localStorage.getItem(cbReverseKey)); } cbReverseIt(); - return logClass; + return logCss; })(); - const stdout = (...args)=>logClass('',...args); - const stderr = (...args)=>logClass('error',...args); + const stdout = (...args)=>logCss('',...args); + const stderr = (...args)=>logCss('error',...args); const wait = async (ms)=>{ return new Promise((resolve)=>setTimeout(resolve,ms)); @@ -67,9 +67,6 @@ const wName = msg.worker; const prefix = 'Worker ['+wName+']:'; switch(msg.type){ - case 'stdout': stdout(prefix,...msg.payload); break; - case 'stderr': stderr(prefix,...msg.payload); break; - case 'error': stderr(prefix,"ERROR:",...msg.payload); break; case 'loaded': stdout(prefix,"loaded"); if(++workers.loadedCount === workers.length){ @@ -77,7 +74,16 @@ workers.post('run'); } break; - default: logClass('error',"Unhandled message type:",msg); break; + case 'stdout': stdout(prefix,...msg.payload); break; + case 'stderr': stderr(prefix,...msg.payload); break; + case 'error': stderr(prefix,"ERROR:",...msg.payload); break; + case 'finished': + logCss('tests-pass',prefix,...msg.payload); + break; + case 'failed': + logCss('tests-fail',prefix,"FAILED:",...msg.payload); + break; + default: logCss('error',"Unhandled message type:",msg); break; } }; diff --git a/ext/wasm/tests/opfs/concurrency/worker.js b/ext/wasm/tests/opfs/concurrency/worker.js index 7ba15bf8c1..9aaa2f4c78 100644 --- a/ext/wasm/tests/opfs/concurrency/worker.js +++ b/ext/wasm/tests/opfs/concurrency/worker.js @@ -26,7 +26,7 @@ self.sqlite3InitModule().then(async function(sqlite3){ wPost('loaded'); const run = async function(){ - const db = new sqlite3.opfs.OpfsDb(dbName); + const db = new sqlite3.opfs.OpfsDb(dbName,'c'); //sqlite3.capi.sqlite3_busy_timeout(db.pointer, 2000); db.transaction((db)=>{ db.exec([ @@ -37,7 +37,7 @@ self.sqlite3InitModule().then(async function(sqlite3){ const maxIterations = 10; const interval = Object.assign(Object.create(null),{ - delay: 300, + delay: 500, handle: undefined, count: 0 }); @@ -58,9 +58,13 @@ self.sqlite3InitModule().then(async function(sqlite3){ } }; const finish = ()=>{ - if(interval.error) stderr("Ending work due to error:",e.message); - else stdout("Ending work after",interval.count,"interval(s)"); db.close(); + if(interval.error){ + wPost('failed',"Ending work after interval #"+interval.count, + "due to error:",interval.error); + }else{ + wPost('finished',"Ending work after",interval.count,"intervals."); + } }; if(1){/*use setInterval()*/ interval.handle = setInterval(async ()=>{ diff --git a/manifest b/manifest index ccf4fd8d76..75a05f7f6c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\sapp\sfor\sexperimenting\swith\smulti-worker\sOPFS\sconcurrency.\sTweak\sOPFS\sVFS\sto\ssignificantly\simprove\sthe\sotherwise\s"unfortunate"\sconcurrency\ssituation. -D 2022-11-21T03:50:52.240 +C Resolve\smissing\sSQLITE_LOCKED\sresult\scode\swhich\striggered\sa\snew\s(since\slast\scheckin)\sexception\sin\sthe\sOPFS\sVFS.\sImprove\soutput\sof\sthe\sOPFS\scontention\stester\sapp. +D 2022-11-21T04:12:38.735 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -502,11 +502,11 @@ F ext/wasm/api/pre-js.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f F ext/wasm/api/sqlite3-api-cleanup.js ecdc69dbfccfe26146f04799fcfd4a6f5790d46e7e3b9b6e9b0491f92ed8ae34 F ext/wasm/api/sqlite3-api-glue.js 056f44b82c126358a0175e08a892d56fadfce177b0d7a0012502a6acf67ea6d5 F ext/wasm/api/sqlite3-api-oo1.js e9a83489bbb4838ce0aee46eaaa9350e0e25a5b926b565e4f5ae8e840e4fbaed -F ext/wasm/api/sqlite3-api-opfs.js 4c75ed11df5efff6bcd8dad4ad904d8b11efac2e1dd4cc2c84d1ee8ace4129ef +F ext/wasm/api/sqlite3-api-opfs.js 38d368e33f470f9ba196f1a2b0c9ce076c930c70df233c345a246f1ad4c26d3b F ext/wasm/api/sqlite3-api-prologue.js 08e96d26d329e8c1e08813fe0b84ee93e0e78b087efdd6eb2809ae2672902437 F ext/wasm/api/sqlite3-api-worker1.js e94ba98e44afccfa482874cd9acb325883ade50ed1f9f9526beb9de1711f182f F ext/wasm/api/sqlite3-license-version-header.js a661182fc93fc2cf212dfd0b987f8e138a3ac98f850b1112e29b5fbdaecc87c3 -F ext/wasm/api/sqlite3-opfs-async-proxy.js 97cf1909670575eced940d36f1b5ea35c51a431d1035dc2f7ea6982faee97c1b +F ext/wasm/api/sqlite3-opfs-async-proxy.js 021af8b3d1754e308c09eebee5f8d235fb245bea1f9b1c1414141cc2ebd5649c F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9 F ext/wasm/api/sqlite3-wasm.c 8fc8f47680df0e9a6c0f2f03cb004148645ecc983aa216daba09cb21f7e092a2 F ext/wasm/api/sqlite3-worker1-promiser.js 0c7a9826dbf82a5ed4e4f7bf7816e825a52aff253afbf3350431f5773faf0e4b @@ -553,8 +553,8 @@ F ext/wasm/tester1-worker.html 5ef353348c37cf2e4fd0b23da562d3275523e036260b51073 F ext/wasm/tester1.c-pp.html 74aa9b31c75f12490653f814b53c3dd39f40cd3f70d6a53a716f4e8587107399 F ext/wasm/tester1.c-pp.js 0c129495d057c77788b59715152d51f9bf9002ebbcce759ef8b028272ce3519d F ext/wasm/tests/opfs/concurrency/index.html c7cf329e5b206dd8226d94ab9fec02f5f350d8ed69a57c96d84e876afd3d3d1b -F ext/wasm/tests/opfs/concurrency/test.js 44cfcc04503593256abe2dd663349718f80ee7ab25e19eb066de220101bd604a -F ext/wasm/tests/opfs/concurrency/worker.js f8f3e4f9b21726bef354a74ec9c90f6736df5b16b4f655bfd16a3b9c6ee063ff +F ext/wasm/tests/opfs/concurrency/test.js 6f7d49d97c27906f8f5a39d6da176122350f375cd811e51182128bc2db74e464 +F ext/wasm/tests/opfs/concurrency/worker.js 571bcc525520fedfc71e25486265247633a4bf8aee554923aa7219399ed749fd F ext/wasm/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd72273503ae7d5 F ext/wasm/wasmfs.make 8fea9b4f3cde06141de1fc4c586ab405bd32c3f401554f4ebb18c797401a678d F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x @@ -2059,8 +2059,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 469f9011a885e19b99210c5e3e582afa140b8b5f0aa7a720334848df5ab6ae98 -R c87fca3e6d0a9c36a2598013e36db2a5 +P 96f76e7616f8157a342b9e1c42f7b1feab200d182268871a2b25f67d4ee2564c +R 37b708b698da9468667dd15ac1e5f125 U stephan -Z b0030359261e278f67d2690556943dbd +Z 415bce67c5fc2cb5709db14ccdfe0252 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2e8d22d1e3..7de2c9eef7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96f76e7616f8157a342b9e1c42f7b1feab200d182268871a2b25f67d4ee2564c \ No newline at end of file +2debbbca33bd4170a1dc4dbb5eb3e68523e51d289b06c551e5560ac4e32e433b \ No newline at end of file