haikuwebkit/LayoutTests/storage/indexeddb/transaction-starvation-expe...

37 lines
964 B
Plaintext
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/122359@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136782 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-12-06 01:30:35 +00:00
Check that read-only transactions don't starve read-write transactions.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
prepareDatabase():
db = event.target.result
db.createObjectStore('store')
runTransactions():
db = event.target.result
readWriteTransactionStarted = false
readWriteTransactionComplete = false
startReadOnlyTransaction():
transaction = db.transaction('store', 'readonly')
store = transaction.objectStore('store')
Keep the transaction alive with an endless series of gets
startReadWriteTransaction():
transaction = db.transaction('store', 'readwrite')
readWriteTransactionStarted = true
readWriteTransactionComplete():
PASS Transaction wasn't starved
readWriteTransactionComplete = true
PASS successfullyParsed is true
TEST COMPLETE