Re: [w3c/IndexedDB] Disallow starting readwrite transactions while readonly transactions are running? (#253)

As things stand, from a standards-perspective, I think the obvious right thing to do is to codify that the readonly transaction must finish before the readwrite can start.  If all code will be written on implementations that assume the tx1 and tx2 transactions and their application logic can't interleave, then it's almost certain there will be emergent application bugs when they can interleave.

**However**, at TPAC 2018 in the ServiceWorkers meeting, there was the ongoing issue of how SWs should deal with complicated issues like LRU eviction from the Cache API.  And a serious proposal was that perhaps we should turn to IndexedDB in those cases (see https://github.com/w3c/ServiceWorker/issues/863#issuecomment-433063809), enabling it to persist Request and Response objects.  Its indices enable all sorts of custom logic and lets us avoid complicating the Cache API.  I think it makes sense to make sure there is a game-plan around the realities of that use-case before changing the spec for this related issue.

If we pursue that course of action, it's likely that we'd have to face the reality of a SW that wants to serve pre-readwrite-transaction data while there's an ongoing readwrite-transaction that's updating the database.  In those cases, it wouldn't be acceptable for "fetch" events to be stalled by a potentially long-running "readwrite" transaction.  A snapshot based mechanism would seem helpful.  However, that could also just be a new type of transaction with new semantics that are "any 'readonly' transactions opened before the 'fancy' transaction completes will see the database's state before the 'fancy' transaction was opened."

(Existing "readonly" transactions wouldn't really work, even with snapshot required, because they would have to be opened prior to the "readwrite" transaction and then spammed with read requests to keep the transaction open under the existing transaction model.  Currently we require any transaction created after the "readwrite" one to see its changes and therefore block on it.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/253#issuecomment-456807181

Received on Wednesday, 23 January 2019 13:48:34 UTC