IndexedDB: Allow multiple transactions to interleave request execution
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Dec 2012 01:30:35 +0000 (01:30 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Dec 2012 01:30:35 +0000 (01:30 +0000)
commitb0acde523deb90da87ccfa26602997c73efae50a
treec583f14ff976b595e5b9c039acb5ad8cfa02e33e
parente93300d16b0cb78c772e48b939e2673ab35de9f0
IndexedDB: Allow multiple transactions to interleave request execution
https://bugs.webkit.org/show_bug.cgi?id=97570

Reviewed by Tony Chang.

Source/WebCore:

Implement spec logic for allowing read-only transactions, and read-write transactions
with non-overlapping scopes, to run concurrently. Transactions all still run in the
same thread with tasks triggered via timers, so tasks and the underlying database
operations are interleaved rather than truly parallelized.

Within IDBTransactionCoordinator, rename started->queued, running->started to match
spec terminology and clear up confusion.

Test: storage/indexeddb/transaction-coordination-across-databases.html
      storage/indexeddb/transaction-coordination-within-database.html
      storage/indexeddb/transaction-readwrite-exclusive.html
      storage/indexeddb/transaction-scope-sequencing.html
      storage/indexeddb/transaction-starvation.html

* Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Use IDBTransaction::Mode enum
(WebCore::IDBDatabaseBackendImpl::createTransaction):
* Modules/indexeddb/IDBDatabaseBackendImpl.h: Ditto.
(IDBDatabaseBackendImpl):
* Modules/indexeddb/IDBDatabaseBackendInterface.h: Ditto.
(IDBDatabaseBackendInterface):
* Modules/indexeddb/IDBTransactionBackendImpl.cpp: Convert scope as a HashSet for
fast intersecting.
(WebCore::IDBTransactionBackendImpl::create):
(WebCore::IDBTransactionBackendImpl::IDBTransactionBackendImpl):
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(IDBTransactionBackendImpl):
(WebCore::IDBTransactionBackendImpl::mode):
(WebCore::IDBTransactionBackendImpl::scope):
* Modules/indexeddb/IDBTransactionCoordinator.cpp: Spec logic goes here.
(WebCore::IDBTransactionCoordinator::processStartedTransactions): Extend this
method to test all plausibly runnable transactions.
(WebCore):
(WebCore::IDBTransactionCoordinator::canRunTransaction): Test to see if one
particular transaction can be run.
(WebCore::IDBTransactionCoordinator::doScopesOverlap): Do a quick intersection
test between transaction scopes.
* Modules/indexeddb/IDBTransactionCoordinator.h:
(IDBTransactionCoordinator):

Source/WebKit/chromium:

Map to IDBTransaction::Mode enum as appropriate.

* src/IDBDatabaseBackendProxy.cpp:
(WebKit::IDBDatabaseBackendProxy::createTransaction):
* src/IDBDatabaseBackendProxy.h:
(IDBDatabaseBackendProxy):
* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::createTransaction):
 * tests/IDBDatabaseBackendTest.cpp:

LayoutTests:

New tests for parallel transactions, update existing tests that relied on sequential execution.

* storage/indexeddb/database-close-expected.txt:
* storage/indexeddb/mozilla/clear-expected.txt:
* storage/indexeddb/mozilla/resources/clear.js: Split up transaction steps.
* storage/indexeddb/resources/database-close.js: Don't log on individual transaction completion.
* storage/indexeddb/resources/transaction-coordination-within-database.js: Added.
* storage/indexeddb/resources/transaction-scope-sequencing.js: Added.
* storage/indexeddb/resources/transaction-starvation.js: Added.
* storage/indexeddb/transaction-coordination-within-database-expected.txt: Added.
* storage/indexeddb/transaction-coordination-within-database.html: Added.
* storage/indexeddb/transaction-scope-sequencing-expected.txt: Added.
* storage/indexeddb/transaction-scope-sequencing.html: Added.
* storage/indexeddb/transaction-starvation-expected.txt: Added.
* storage/indexeddb/transaction-starvation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136782 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/database-close-expected.txt
LayoutTests/storage/indexeddb/mozilla/clear-expected.txt
LayoutTests/storage/indexeddb/mozilla/resources/clear.js
LayoutTests/storage/indexeddb/resources/database-close.js
LayoutTests/storage/indexeddb/resources/transaction-coordination-within-database.js [new file with mode: 0644]
LayoutTests/storage/indexeddb/resources/transaction-scope-sequencing.js [new file with mode: 0644]
LayoutTests/storage/indexeddb/resources/transaction-starvation.js [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-coordination-within-database-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-coordination-within-database.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-scope-sequencing-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-scope-sequencing.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-starvation-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/transaction-starvation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp
Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h
Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp
Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp