litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free

Other
5 stars 0 forks source link

Parallel database access handles #8

Open brodycj opened 6 years ago

brodycj commented 6 years ago

Parallel database access from multiple main/worker threads can be problematic for reasons discussed in #3. (Parallel database access handles would also be key to solving cordova-sqlite-storage bug 666 correctly in this plugin version as discussed in #7.) I think the most correct solution is to use parallel database access handles in a similar fashion to https://github.com/brodybits/cordova-sqlite-evmax-legacy-exp-free, assuming the parallel reader/writer interference issue in https://github.com/brodybits/cordova-sqlite-evmax-legacy-exp-free/issues/1 is solved.

Parallel writer interference could also be an issue in case of parallel database handles in this plugin version due to access from multiple JavaScript threads. The one solution I can think of is to deal with the interference problem on the native side.

An alternative solution to the interference problem would be to WAL mode. As documented in (https://www.sqlite.org/wal.html#overview):

WAL provides more concurrency as readers do not block writers and a writer does not block readers. Reading and writing can proceed concurrently.

Another advantage of WAL is that it may be more robust against possible corruption. From https://github.com/litehelpers/Cordova-sqlite-help/issues/10#issuecomment-354461374:

I was thinking that WAL may be more robust against possible database corruption and found a couple threads that confirm WAL may be more reliable, at least in certain cases: