From b4bb434eff2eab029d47447a46e1a3c7f33a8d71 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 17 Apr 2020 16:32:32 -0700 Subject: [PATCH] Initial sketch of manual commit fix/add 'new in this edition' hints version history invert flag check don't let tx go inactive post-rebase cleanup --- index.bs | 142 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 125 insertions(+), 17 deletions(-) diff --git a/index.bs b/index.bs index 127dfd0..ef8bd96 100644 --- a/index.bs +++ b/index.bs @@ -934,6 +934,8 @@ following: instead is created automatically when an `upgradeneeded` event is fired. +A [=/transaction=] has an manual commit flag, which is initially false. By default, transactions commit automatically when all outstanding requests have been processed. This can be behavior can be modified by options set when creating the transaction. + A [=/transaction=] has a durability hint. This is a hint to the user agent of whether to prioritize performance or durability when committing the transaction. The [=transaction/durability hint=] is one of the following: : {{"strict"}} @@ -1041,10 +1043,11 @@ The lifetime of a 1. When each [=/request=] associated with a transaction is [=request/processed=], - a `success` or `error` [=event=] will be - fired. While the event is being [=dispatched=], the transaction + a `success` or `error` [=event=] will be fired. + If the transaction's [=transaction/manual commit flag=] is false (the default), then + while the event is being [=dispatched=], the transaction [=transaction/state=] is set to [=transaction/active=], allowing - additional requests to be made against the transaction. Once the + additional requests to be made against the transaction; once the event dispatch is complete, the transaction's [=transaction/state=] is set to [=transaction/inactive=] again. @@ -1063,11 +1066,12 @@ The lifetime of a [=/object stores=] as well as additions and removals of [=/object stores=] and [=/indexes=]. -1. The implementation must attempt to commit - a transaction when all [=/requests=] placed against the +1. If a transaction's [=transaction/manual commit flag=] is false, then + the implementation must attempt to commit + it when all [=/requests=] placed against the transaction have completed and their returned results handled, no new requests have been placed against the transaction, and the - transaction has not been [=transaction/aborted=] + transaction has not been [=transaction/aborted=]. An explicit call to {{IDBTransaction/commit()}} will initiate a [=transaction/commit=] without waiting for request results to be @@ -1103,7 +1107,7 @@ They will return true if any transactions were cleaned up, or false otherwise. 1. For each [=/transaction=] |transaction| with [=transaction/cleanup event loop=] matching the current [=/event loop=]: - 1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=]. + 1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=]. 1. Clear |transaction|'s [=transaction/cleanup event loop=]. @@ -1124,6 +1128,78 @@ 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} @@ -2435,6 +2511,7 @@ interface IDBDatabase : EventTarget { enum IDBTransactionDurability { "default", "strict", "relaxed" }; dictionary IDBTransactionOptions { + boolean manualCommit = false; IDBTransactionDurability durability = "default"; }; @@ -2624,9 +2701,13 @@ instance on which it was called. Returns a new [=/transaction=] with the given |scope| (which can be a single [=/object store=] [=object-store/name=] or an array of [=object-store/names=]), |mode| ({{"readonly"}} or {{"readwrite"}}), - and additional |options| including {{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}). + and additional |options| including + {{IDBTransactionOptions/manualCommit}} (true or false), and + {{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}). - The default |mode| is {{"readonly"}} and the default {{IDBTransactionOptions/durability}} is {{"default"}}. + The default |mode| is {{"readonly"}}. + The default {{IDBTransactionOptions/manualCommit}} is false. + The default {{IDBTransactionOptions/durability}} is {{"default"}}. : |connection| . {{IDBDatabase/close()|close}}() :: @@ -2657,7 +2738,11 @@ The transaction(|storeNames|, |mode|, |options|)transaction(|storeNames|, |mode|, |options|) + +