You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The phrase "a transaction is running" was not normatively defined and
confusing given the complex lifecycle of transactions. Introduce a new
definition for "live" which covers from a transactions creation until
it is finished.
Also, rename "running an upgrade transaction" since steps are often
invoked with "run" and that could get awkward. Simplify to "upgrade a
database".
No behavior changes, just normative terminology definitions.
Resolves#408. Thanks to @evanstade the issue and suggestions.
Co-authored-by: Austin Sullivan <[email protected]>
Copy file name to clipboardExpand all lines: index.bs
+31-27Lines changed: 31 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -474,7 +474,7 @@ A [=/connection=] has an <dfn>object store set</dfn>, which is
474
474
initialized to the set of [=/object stores=] in the associated
475
475
[=/database=] when the [=/connection=] is created. The contents of the
476
476
set will remain constant except when an [=/upgrade transaction=] is
477
-
running.
477
+
[=transaction/live=].
478
478
479
479
A [=/connection=]'s [=get the parent=] algorithm returns
480
480
null.
@@ -553,13 +553,13 @@ An [=/object store handle=] has an <dfn>index set</dfn>, which is
553
553
initialized to the set of [=/indexes=] that reference the associated
554
554
[=object-store-handle/object store=] when the [=/object store handle=]
555
555
is created. The contents of the set will remain constant except when
556
-
an [=/upgrade transaction=] is running.
556
+
an [=/upgrade transaction=] is [=transaction/live=].
557
557
558
558
An [=/object store handle=] has a <dfn>name</dfn>, which is
559
559
initialized to the [=object-store/name=] of the associated
560
560
[=object-store-handle/object store=] when the [=/object store handle=]
561
561
is created. The name will remain constant except when an [=/upgrade
562
-
transaction=] is running.
562
+
transaction=] is [=transaction/live=].
563
563
564
564
</div>
565
565
@@ -866,7 +866,7 @@ particular [=/index=] within a [=/transaction=].
866
866
An [=index handle=] has a <dfn>name</dfn>, which is initialized to the
867
867
[=index/name=] of the associated [=index-handle/index=] when the
868
868
[=index handle=] is created. The name will remain constant except when
869
-
an [=/upgrade transaction=] is running.
869
+
an [=/upgrade transaction=] is [=transaction/live=].
870
870
871
871
</div>
872
872
@@ -905,7 +905,7 @@ following:
905
905
::
906
906
The transaction is only allowed to read data. No modifications can
907
907
be done by this type of transaction. This has the advantage that
908
-
several [=transaction/read-only transactions=] can run at the same time even
908
+
several [=transaction/read-only transactions=] can be [=transaction/started=] at the same time even
909
909
if their [=transaction/scopes=] are [=transaction/overlapping=], i.e. if they are using the
910
910
same object stores. This type of transaction can be created any
911
911
time once a database has been opened.
@@ -915,7 +915,7 @@ following:
915
915
The transaction is allowed to read, modify and delete data from
916
916
existing object stores. However object stores and indexes can't be
917
917
added or removed. Multiple "{{IDBTransactionMode/readwrite}}" transactions
918
-
can't run at the same time if their [=transaction/scopes=] are [=transaction/overlapping=]
918
+
can't be [=transaction/started=] at the same time if their [=transaction/scopes=] are [=transaction/overlapping=]
919
919
since that would mean that they can modify each other's data in
920
920
the middle of the transaction. This type of transaction can be
921
921
created any time once a database has been opened.
@@ -1001,7 +1001,7 @@ Transactions are expected to be short lived. This is encouraged by the
1001
1001
described below.
1002
1002
1003
1003
<aside class=note>
1004
-
Authors can still cause transactions to run for a long time;
1004
+
Authors can still cause transactions to stay [=transaction/live|alive=] for a long time;
1005
1005
however, this usage pattern is not advised as it can lead to a poor
1006
1006
user experience.
1007
1007
</aside>
@@ -1088,6 +1088,8 @@ the case even if the transaction has not yet been
1088
1088
requests; however, the implementation must keep track of the
1089
1089
[=/requests=] and their order.
1090
1090
1091
+
A [=/transaction=] is said to be <dfn>live</dfn> from when it is [=transaction/created=] until its [=transaction/state=] is set to [=transaction/finished=].
1092
+
1091
1093
<div algorithm>
1092
1094
1093
1095
To <dfn id=cleanup-indexed-database-transactions export>cleanup Indexed Database transactions</dfn>, run the following steps.
@@ -1135,14 +1137,14 @@ The following constraints define when a [=/transaction=] can be [=transaction/st
1135
1137
* have [=transaction/overlapping scopes=] with |tx|; and
1136
1138
* are not [=transaction/finished=].
1137
1139
1138
-
Implementations may impose additional constraints. For example, implementations are not required to run non-[=transaction/overlapping=]<a for=transaction>read/write transactions</a> in parallel, or may impose limits on the number of running transactions.
1140
+
Implementations may impose additional constraints. For example, implementations are not required to [=transaction/start=] non-[=transaction/overlapping=]<a for=transaction>read/write transactions</a> in parallel, or may impose limits on the number of [=transaction/started=] transactions.
1139
1141
1140
1142
<aside class=note>
1141
1143
1142
1144
These constraints imply the following:
1143
1145
1144
-
* Any number of [=transaction/read-only transactions=] are allowed to run concurrently, even if they have [=transaction/overlapping scopes=].
1145
-
* As long as a [=transaction/read-only transaction=] is running, the data that the implementation returns through [=/requests=] created with that transaction remains constant. That is, two requests to read the same piece of data 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.
1146
+
* Any number of [=transaction/read-only transactions=] are allowed to be [=transaction/started=] concurrently, even if they have [=transaction/overlapping scopes=].
1147
+
* As long as a [=transaction/read-only transaction=] is [=transaction/live=], the data that the implementation returns through [=/requests=] created with that transaction remains constant. That is, two requests to read the same piece of data 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.
1146
1148
* A <a for=transaction>read/write transaction</a> is only affected by changes to [=/object stores=] that are made using the transaction itself. The implementation ensures that another transaction does not modify the contents of [=/object stores=] in the <a for=transaction>read/write transaction</a>'s [=transaction/scope=]. The implementation also ensures that if the <a for=transaction>read/write transaction</a> completes successfully, the changes written to [=/object stores=] using the transaction can be committed to the [=/database=] without merge conflicts.
1147
1149
* If multiple <a for=transaction>read/write transactions</a> are attempting to access the same object store (i.e. if they have [=transaction/overlapping scopes=]), the transaction that was [=transaction/created=] first is the transaction which gets access to the object store first, and it is the only transaction which has access to the object store until the transaction is [=transaction/finished=].
1148
1150
* Any transaction [=transaction/created=] after a <a for=transaction>read/write transaction</a> sees the changes written by the <a for=transaction>read/write transaction</a>. For example, if a <a for=transaction>read/write transaction</a> A, is created, and later another transaction B, is created, and the two transactions have [=transaction/overlapping scopes=], then transaction B sees any changes made to any [=/object stores=] that are part of that [=transaction/overlapping scope=]. This also means that transaction B does not have access to any [=/object stores=] in that overlapping [=transaction/scope=] until transaction A is [=transaction/finished=].
@@ -1159,7 +1161,7 @@ An <dfn>upgrade transaction</dfn> is a [=/transaction=] with [=transaction/mode=
1159
1161
"{{IDBTransactionMode/versionchange}}".
1160
1162
1161
1163
An [=/upgrade transaction=] is automatically created when running the
1162
-
steps to [=run an upgrade transaction=] after a [=/connection=]
1164
+
steps to [=upgrade a database=] after a [=/connection=]
1163
1165
is opened to a [=/database=], if a [=database/version=] greater than
1164
1166
the current [=database/version=] is specified. This [=/transaction=]
1165
1167
will be active inside the {{IDBOpenDBRequest/upgradeneeded!!event}} event
@@ -1171,21 +1173,23 @@ handler.
1171
1173
1172
1174
An [=/upgrade transaction=] is exclusive. The steps to [=open a
1173
1175
database=] ensure that only one [=/connection=] to the database is
1174
-
open when an [=/upgrade transaction=] is running.
1176
+
open when an [=/upgrade transaction=] is [=transaction/live=].
1175
1177
The {{IDBOpenDBRequest/upgradeneeded!!event}} event isn't fired, and thus the
1176
1178
[=/upgrade transaction=] isn't started, until all other
1177
1179
[=/connections=] to the same [=/database=] are closed. This ensures
1178
-
that all previous transactions are [=transaction/finished=]. As long
1179
-
as an [=/upgrade transaction=] is running, attempts to open more
1180
+
that all previous transactions are [=transaction/finished=].
1181
+
1182
+
As long
1183
+
as an [=/upgrade transaction=] is [=transaction/live=], attempts to open more
1180
1184
[=/connections=] to the same [=/database=] are delayed, and any
1181
1185
attempts to use the same [=/connection=] to start additional
1182
1186
transactions by calling {{IDBDatabase/transaction()}} will throw an
1183
-
exception. Thus [=/upgrade transactions=] not only ensure that no
1184
-
other transactions are running concurrently, but also ensure that no
1187
+
exception. This ensures that no
1188
+
other transactions are [=transaction/live=] concurrently, and also ensures that no
1185
1189
new transactions are queued against the same [=/database=] as long
1186
-
as the transaction is running.
1190
+
as the [=/upgrade transaction=] is [=transaction/live=].
1187
1191
1188
-
This ensures that once an [=/upgrade transaction=] is complete, the
1192
+
This further ensures that once an [=/upgrade transaction=] is complete, the
1189
1193
set of [=/object stores=] and [=/indexes=] in a [=/database=] remain
1190
1194
constant for the lifetime of all subsequent [=/connections=] and
1191
1195
[=/transactions=].
@@ -1996,7 +2000,7 @@ enum IDBRequestReadyState {
1996
2000
::
1997
2001
Returns the {{IDBTransaction}} the request was made within.
1998
2002
If this as an [=request/open request=], then it returns an
1999
-
[=/upgrade transaction=] while it is running, or null otherwise.
2003
+
[=/upgrade transaction=] while it is [=transaction/live=], or null otherwise.
The <dfn attribute for=IDBVersionChangeEvent>oldVersion</dfn> getter steps are to return the value it was initialized to. It represents the previous version of the database.
2084
2088
2085
2089
2086
-
The <dfn attribute for=IDBVersionChangeEvent>newVersion</dfn> getter steps are to return the value it was initialized to. It represents the new version of the database, or null if the database is being deleted. See the steps to [=run an upgrade transaction=].
2090
+
The <dfn attribute for=IDBVersionChangeEvent>newVersion</dfn> getter steps are to return the value it was initialized to. It represents the new version of the database, or null if the database is being deleted. See the steps to [=upgrade a database=].
2087
2091
2088
2092
Events are constructed as defined in [[DOM#constructing-events]].
2089
2093
@@ -2636,7 +2640,7 @@ instance on which it was called.
2636
2640
2637
2641
The <dfn method for=IDBDatabase>transaction(|storeNames|, |mode|, |options|)</dfn> method steps are:
2638
2642
2639
-
1. If a running[=/upgrade transaction=] is associated with the [=/connection=],
2643
+
1. If a [=transaction/live=][=/upgrade transaction=] is associated with the [=/connection=],
2640
2644
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
2641
2645
2642
2646
1. If [=/this=]'s [=connection/close pending flag=] is true, then [=exception/throw=] an
@@ -4996,7 +5000,7 @@ To <dfn>open a database</dfn> with |storageKey| which requested the [=/database=
4996
5000
[=/connections=] in |openConnections| are
4997
5001
[=connection/closed=].
4998
5002
4999
-
1. Run [=run an upgrade transaction=]
5003
+
1. Run [=upgrade a database=]
5000
5004
using |connection|, |version| and |request|.
5001
5005
5002
5006
1. If |connection| was [=connection/closed=],
@@ -5052,7 +5056,7 @@ optional |forced flag|, run these steps:
5052
5056
5053
5057
<aside class=note>
5054
5058
Once the [=/connection=] is closed, this can unblock the steps to
5055
-
[=run an upgrade transaction=], and the steps to [=delete a
5059
+
[=upgrade a database=], and the steps to [=delete a
5056
5060
database=], which [both](#delete-close-block)
5057
5061
[wait](#version-change-close-block) for [=/connections=] to
5058
5062
a given [=/database=] to be closed before continuing.
@@ -5297,14 +5301,12 @@ created [=/request=] belongs to is [=transaction/aborted=] using the steps to
To <dfn>run an upgrade transaction</dfn> with |connection| (a [=/connection=])
5306
-
which is used to update the [=/database=], a new |version| to be set
5307
-
for the [=/database=], and a |request|, run these steps:
5309
+
To <dfn>upgrade a database</dfn> with |connection| (a [=/connection=]), a new |version|, and a |request|, run these steps:
5308
5310
5309
5311
1. Let |db| be |connection|'s [=/database=].
5310
5312
@@ -6781,6 +6783,7 @@ For the revision history of the second edition, see [that document's Revision Hi
6781
6783
* 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))
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
6786
+
* Added a definition for [=transaction/live=] transactions, and renamed "run an upgrade transaction" to [=/upgrade a database=], to disambiguate "running". ([Issue #408](https://github.com/w3c/IndexedDB/issues/408))
0 commit comments