From c9ec27a3603133159d3fa1ee5d21db5c9d2915ab Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 26 Feb 2020 16:07:57 -0800 Subject: [PATCH 1/3] Simplify transaction starting constraints to match reality All implementations have a strict ordering of transactions with overlapping scopes; read-only transactions can run in parallel but block a later read/write transaction from starting, and the read/write transactions similarly block later read/write and read-only transactions. Tighten up the constraints definition to something precise, and move the wordy implications into a non-normative aside. Also, define "overlapping scopes" as a term. Closes #253 --- index.bs | 91 ++++++++++++++------------------------------------------ 1 file changed, 22 insertions(+), 69 deletions(-) diff --git a/index.bs b/index.bs index 4de017b..16eef63 100644 --- a/index.bs +++ b/index.bs @@ -892,10 +892,9 @@ and data mutation operations. All transactions are created through a [=/connection=], which is the transaction's connection. -A [=/transaction=] has a scope that determines the -[=/object stores=] with which the transaction may interact. A -transaction's scope remains fixed for the lifetime of that -transaction. +A [=/transaction=] has a scope which is a [=/set=] of [=/object stores=] that the transaction may interact with. A transaction's scope remains fixed for the lifetime of that transaction. + +Two [=/transactions=] have overlapping scope if any [=/object store=] is in both transactions' [=transaction/scope=]. A [=/transaction=] has a mode that determines which types of interactions can be performed upon that transaction. The [=transaction/mode=] @@ -908,7 +907,7 @@ following: The transaction is only allowed to read data. No modifications can be done by this type of transaction. This has the advantage that several [=read-only transactions=] can run at the same time even - if their [=transaction/scopes=] are overlapping, i.e. if they are using the + if their [=transaction/scopes=] are [=overlapping=], i.e. if they are using the same object stores. This type of transaction can be created any time once a database has been opened. @@ -917,7 +916,7 @@ following: The transaction is allowed to read, modify and delete data from existing object stores. However object stores and indexes can't be added or removed. Multiple {{"readwrite"}} transactions - can't run at the same time if their [=transaction/scopes=] are overlapping + can't run at the same time if their [=transaction/scopes=] are [=overlapping=] since that would mean that they can modify each other's data in the middle of the transaction. This type of transaction can be created any time once a database has been opened. @@ -1125,74 +1124,28 @@ a [=/transaction=] that has successfully [=transaction/committed=]. An event with type `abort` is fired at a [=/transaction=] that has [=transaction/aborted=]. -The following constraints define when a [=/transaction=] can be -[=transaction/started=]: +The following constraints define when a [=/transaction=] can be [=transaction/started=]: -* Any number of [=read-only transactions=] are allowed to run - concurrently, even if the transaction's [=transaction/scope=] overlap and - include the same [=/object stores=]. As long as a [=read-only - transaction=] is running, the data that the implementation returns - through [=/requests=] created with that transaction must remain - constant. That is, two requests to read the same piece of data - must yield the same result both for the case when data is found - and the result is that data, and for the case when data is not - found and a lack of data is indicated. +* A [=read-only transactions=] |tx| can [=transaction/start=] when there are no read/write transactions which: + * Were [=transaction/created=] before |tx|; and + * have [=overlapping scopes=] with |tx|; and + * are not [=transaction/finished=]. +* A read/write transaction |tx| can [=transaction/start=] when there are no [=/transactions=] which: + * Were [=transaction/created=] before |tx|; and + * have [=overlapping scopes=] with |tx|; and + * are not [=transaction/finished=]. - + From 12328160c556899e05ac4c26df865761b84469bf Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 26 Feb 2020 16:19:21 -0800 Subject: [PATCH 2/3] revision history --- index.bs | 1 + 1 file changed, 1 insertion(+) diff --git a/index.bs b/index.bs index 16eef63..27250b2 100644 --- a/index.bs +++ b/index.bs @@ -6817,6 +6817,7 @@ For the revision history of the second edition, see [that document's Revision Hi * Restrict array keys to [=/Array exotic objects=] (i.e. disallow proxies). ([Issue #309](https://github.com/w3c/IndexedDB/issues/309)) * Transactions are now temporarily made inactive during clone operations. * Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50)) +* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253)) # Acknowledgements # {#acknowledgements} From ef63c2847e76199d90207d67a44360cd886bc07b Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Thu, 27 Feb 2020 14:12:55 -0800 Subject: [PATCH 3/3] may impose additional constraints --- index.bs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 27250b2..82f9c67 100644 --- a/index.bs +++ b/index.bs @@ -1114,16 +1114,16 @@ They will return true if any transactions were cleaned up, or false otherwise. each [=/transaction=]. - -### Transaction scheduling ### {#transaction-scheduling} - - An event with type `complete` is fired at a [=/transaction=] that has successfully [=transaction/committed=]. An event with type `abort` is fired at a [=/transaction=] that has [=transaction/aborted=]. + +### Transaction scheduling ### {#transaction-scheduling} + + The following constraints define when a [=/transaction=] can be [=transaction/started=]: * A [=read-only transactions=] |tx| can [=transaction/start=] when there are no read/write transactions which: @@ -1135,6 +1135,8 @@ The following constraints define when a [=/transaction=] can be [=transaction/st * have [=overlapping scopes=] with |tx|; and * are not [=transaction/finished=]. +Implementations may impose additional constraints. For example, implementations are not required to run non-[=overlapping=] read/write transactions in parallel, or may impose limits on the number of running transactions. +