Title: [170327] trunk
Revision
170327
Author
jp...@apple.com
Date
2014-06-23 15:38:47 -0700 (Mon, 23 Jun 2014)

Log Message

Database process crashes when multiple transactions attempt to run at once
https://bugs.webkit.org/show_bug.cgi?id=134139

Reviewed by David Kilzer.

Source/WebCore:
Ensure that only one transaction can be running at a time.

Test: storage/indexeddb/transaction-overlapping.html

* Modules/indexeddb/IDBTransactionCoordinator.cpp:
(WebCore::IDBTransactionCoordinator::canRunTransaction):

LayoutTests:
* storage/indexeddb/transaction-overlapping-expected.txt: Added.
* storage/indexeddb/transaction-overlapping.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (170326 => 170327)


--- trunk/LayoutTests/ChangeLog	2014-06-23 22:12:49 UTC (rev 170326)
+++ trunk/LayoutTests/ChangeLog	2014-06-23 22:38:47 UTC (rev 170327)
@@ -1,3 +1,13 @@
+2014-06-19  Jeffrey Pfau  <jp...@apple.com>
+
+        Database process crashes when multiple transactions attempt to run at once
+        https://bugs.webkit.org/show_bug.cgi?id=134139
+
+        Reviewed by David Kilzer.
+
+        * storage/indexeddb/transaction-overlapping-expected.txt: Added.
+        * storage/indexeddb/transaction-overlapping.html: Added.
+
 2014-06-23  Antti Koivisto  <an...@apple.com>
 
         Fix a test case failing on WK1 after r170296.

Added: trunk/LayoutTests/storage/indexeddb/transaction-overlapping-expected.txt (0 => 170327)


--- trunk/LayoutTests/storage/indexeddb/transaction-overlapping-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/transaction-overlapping-expected.txt	2014-06-23 22:38:47 UTC (rev 170327)
@@ -0,0 +1,35 @@
+Check that transactions that may overlap complete properly.
+
+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;
+
+dbname = "transaction-overlapping.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+
+prepareDatabase():
+db = event.target.result
+store = db.createObjectStore('store')
+store.put('value', 'key')
+
+runParallelTransactions():
+db = event.target.result
+
+transaction1 = db.transaction('store', 'readonly')
+transaction2 = db.transaction('store', 'readonly')
+transaction1GetSuccess = 0
+transaction2GetSuccess = 0
+
+onTransactionComplete():
+first transaction complete, still waiting...
+
+onTransactionComplete():
+PASS transaction1GetSuccess is non-zero.
+PASS transaction2GetSuccess is non-zero.
+db.close()
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/transaction-overlapping.html (0 => 170327)


--- trunk/LayoutTests/storage/indexeddb/transaction-overlapping.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/transaction-overlapping.html	2014-06-23 22:38:47 UTC (rev 170327)
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+description("Check that transactions that may overlap complete properly.");
+
+indexedDBTest(prepareDatabase, runParallelTransactions);
+
+function prepareDatabase(evt)
+{
+    preamble(evt);
+    evalAndLog("db = event.target.result");
+    evalAndLog("store = db.createObjectStore('store')");
+    evalAndLog("store.put('value', 'key')");
+}
+
+function runParallelTransactions(evt)
+{
+    preamble(evt);
+    evalAndLog("db = event.target.result");
+    debug("");
+    evalAndLog("transaction1 = db.transaction('store', 'readonly')");
+    transaction1._onabort_ = unexpectedAbortCallback;
+    transaction1._oncomplete_ = onTransactionComplete;
+    evalAndLog("transaction2 = db.transaction('store', 'readonly')");
+    transaction1._onabort_ = unexpectedAbortCallback;
+    transaction2._oncomplete_ = onTransactionComplete;
+
+    evalAndLog("transaction1GetSuccess = 0");
+    evalAndLog("transaction2GetSuccess = 0");
+
+    function doTransaction1Get() {
+        // NOTE: No logging since execution order is not deterministic.
+        request = transaction1.objectStore('store').get('key');
+        request._onerror_ = unexpectedErrorCallback;
+        request._onsuccess_ = function() {
+            ++transaction1GetSuccess;
+            if (!transaction2GetSuccess && transaction1GetSuccess < 10)
+                doTransaction1Get();
+        };
+    }
+
+    function doTransaction2Get() {
+        // NOTE: No logging since execution order is not deterministic.
+        request = transaction2.objectStore('store').get('key');
+        request._onerror_ = unexpectedErrorCallback;
+        request._onsuccess_ = function() {
+            ++transaction2GetSuccess;
+            if (!transaction1GetSuccess && transaction2GetSuccess < 10)
+                doTransaction2Get();
+        };
+    }
+
+    doTransaction1Get();
+    doTransaction2Get();
+}
+
+transactionCompletionCount = 0;
+function onTransactionComplete(evt)
+{
+    preamble(evt);
+
+    ++transactionCompletionCount;
+    if (transactionCompletionCount < 2) {
+        debug("first transaction complete, still waiting...");
+        return;
+    }
+
+    shouldBeNonZero("transaction1GetSuccess");
+    shouldBeNonZero("transaction2GetSuccess");
+
+    evalAndLog("db.close()");
+    finishJSTest();
+}
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (170326 => 170327)


--- trunk/Source/WebCore/ChangeLog	2014-06-23 22:12:49 UTC (rev 170326)
+++ trunk/Source/WebCore/ChangeLog	2014-06-23 22:38:47 UTC (rev 170327)
@@ -1,3 +1,17 @@
+2014-06-19  Jeffrey Pfau  <jp...@apple.com>
+
+        Database process crashes when multiple transactions attempt to run at once
+        https://bugs.webkit.org/show_bug.cgi?id=134139
+
+        Reviewed by David Kilzer.
+
+        Ensure that only one transaction can be running at a time.
+
+        Test: storage/indexeddb/transaction-overlapping.html
+
+        * Modules/indexeddb/IDBTransactionCoordinator.cpp:
+        (WebCore::IDBTransactionCoordinator::canRunTransaction):
+
 2014-06-23  Benjamin Poulain  <bpoul...@apple.com>
 
         [iOS][WK2] Make the state restore from HistoryItem more precise and reliable

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp (170326 => 170327)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp	2014-06-23 22:12:49 UTC (rev 170326)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp	2014-06-23 22:38:47 UTC (rev 170327)
@@ -105,6 +105,7 @@
     }
 }
 
+#if USE(LEVELDB)
 static bool doScopesOverlap(const HashSet<int64_t>& scope1, const HashSet<int64_t>& scope2)
 {
     for (HashSet<int64_t>::const_iterator it = scope1.begin(); it != scope1.end(); ++it) {
@@ -113,10 +114,13 @@
     }
     return false;
 }
+#endif
 
 bool IDBTransactionCoordinator::canRunTransaction(IDBTransactionBackend* transaction)
 {
     ASSERT(m_queuedTransactions.contains(transaction));
+
+#if USE(LEVELDB)
     switch (transaction->mode()) {
     case IndexedDB::TransactionMode::VersionChange:
         ASSERT(m_queuedTransactions.size() == 1);
@@ -140,6 +144,9 @@
     }
     ASSERT_NOT_REACHED();
     return false;
+#else
+    return !m_startedTransactions.size();
+#endif
 }
 
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to