Modern IDB: storage/indexeddb/dont-wedge.html is flaky.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jan 2016 19:17:45 +0000 (19:17 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jan 2016 19:17:45 +0000 (19:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152892

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (Reenabled existing test).

* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::abortOpenAndUpgradeNeeded):
* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/client/IDBConnectionToServerDelegate.h:

* Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
(WebCore::IDBClient::IDBOpenDBRequest::requestCompleted): If the database was opened
  or an upgrade transaction was started, but the script execution context is already
  stopped, immediately message back to the server so it doesn't wedge.

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::abortOpenAndUpgradeNeeded):
* Modules/indexeddb/server/IDBServer.h:

* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::abortWithoutCallback):
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:

* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::abortOpenAndUpgradeNeeded):
* Modules/indexeddb/shared/InProcessIDBServer.h:

LayoutTests:

* platform/mac-wk1/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h
Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp
Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
Source/WebCore/Modules/indexeddb/server/IDBServer.h
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h

index 806e9ad..02cc0e2 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-12  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: storage/indexeddb/dont-wedge.html is flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=152892
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-12  Antti Koivisto  <antti@apple.com>
 
         Don't reuse memory cache entries with different charset
index da28ad0..4ae5388 100644 (file)
@@ -93,9 +93,6 @@ storage/indexeddb/cursor-request-cycle.html [ Failure ]
 storage/indexeddb/delete-closed-database-object.html [ Skip ]
 storage/indexeddb/request-leak.html [ Failure ]
 
-# Flaky timeout on the bots
-webkit.org/b/152892 storage/indexeddb/dont-wedge.html [ Pass Timeout ]
-
 # No workers support in Modern IDB yet
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
index efee494..88f915a 100644 (file)
@@ -1,3 +1,34 @@
+2016-01-12  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: storage/indexeddb/dont-wedge.html is flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=152892
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Reenabled existing test).
+
+        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+        (WebCore::IDBClient::IDBConnectionToServer::abortOpenAndUpgradeNeeded):
+        * Modules/indexeddb/client/IDBConnectionToServer.h:
+        * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
+
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBOpenDBRequest::requestCompleted): If the database was opened
+          or an upgrade transaction was started, but the script execution context is already
+          stopped, immediately message back to the server so it doesn't wedge.
+
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::abortOpenAndUpgradeNeeded):
+        * Modules/indexeddb/server/IDBServer.h:
+
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::abortWithoutCallback):
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
+
+        * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+        (WebCore::InProcessIDBServer::abortOpenAndUpgradeNeeded):
+        * Modules/indexeddb/shared/InProcessIDBServer.h:
+
 2016-01-12  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r194826.
index c6022d9..b20b9c6 100644 (file)
@@ -362,6 +362,13 @@ void IDBConnectionToServer::databaseConnectionClosed(IDBDatabase& database)
     m_delegate->databaseConnectionClosed(database.databaseConnectionIdentifier());
 }
 
+void IDBConnectionToServer::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+    LOG(IndexedDB, "IDBConnectionToServer::abortOpenAndUpgradeNeeded");
+
+    m_delegate->abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
+}
+
 void IDBConnectionToServer::registerDatabaseConnection(IDBDatabase& database)
 {
     ASSERT(!m_databaseConnectionMap.contains(database.databaseConnectionIdentifier()));
index 9fac8fb..98472f3 100644 (file)
@@ -112,6 +112,11 @@ public:
     void establishTransaction(IDBTransaction&);
 
     void databaseConnectionClosed(IDBDatabase&);
+
+    // To be used when an IDBOpenDBRequest gets a new database connection, optionally with a
+    // versionchange transaction, but the page is already torn down.
+    void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
+    
     void registerDatabaseConnection(IDBDatabase&);
     void unregisterDatabaseConnection(IDBDatabase&);
 
index f21c48c..fe897bd 100644 (file)
@@ -74,6 +74,7 @@ public:
 
     virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) = 0;
     virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) = 0;
+    virtual void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier) = 0;
     virtual void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier) = 0;
 
     virtual void ref() = 0;
index d72511d..10a6624 100644 (file)
@@ -165,8 +165,23 @@ void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
 {
     LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
 
-    if (m_contextStopped)
+    // If an Open request was completed after the page has navigated, leaving this request
+    // with a stopped script execution context, we need to message back to the server so it
+    // doesn't hang waiting on a database connection or transaction that will never exist.
+    if (m_contextStopped) {
+        switch (data.type()) {
+        case IDBResultType::OpenDatabaseSuccess:
+            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
+            break;
+        case IDBResultType::OpenDatabaseUpgradeNeeded:
+            connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
+            break;
+        default:
+            break;
+        }
+
         return;
+    }
 
     switch (data.type()) {
     case IDBResultType::Error:
index 3f44a09..d6bfa55 100644 (file)
@@ -339,6 +339,21 @@ void IDBServer::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
     databaseConnection->connectionClosedFromClient();
 }
 
+void IDBServer::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+    LOG(IndexedDB, "IDBServer::abortOpenAndUpgradeNeeded");
+
+    auto transaction = m_transactions.get(transactionIdentifier);
+    if (transaction)
+        transaction->abortWithoutCallback();
+
+    auto databaseConnection = m_databaseConnections.get(databaseConnectionIdentifier);
+    if (!databaseConnection)
+        return;
+
+    databaseConnection->connectionClosedFromClient();
+}
+
 void IDBServer::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier)
 {
     LOG(IndexedDB, "IDBServer::didFireVersionChangeEvent");
index c4d27f7..99f486b 100644 (file)
@@ -75,6 +75,7 @@ public:
 
     void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
     void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
+    void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
     void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);
 
     void postDatabaseTask(std::unique_ptr<CrossThreadTask>&&);
index 7e991ff..868133b 100644 (file)
@@ -75,6 +75,13 @@ void UniqueIDBDatabaseTransaction::abort()
     });
 }
 
+void UniqueIDBDatabaseTransaction::abortWithoutCallback()
+{
+    LOG(IndexedDB, "UniqueIDBDatabaseTransaction::abortWithoutCallback");
+
+    m_databaseConnection->database().abortTransaction(*this, [](const IDBError&) { });
+}
+
 bool UniqueIDBDatabaseTransaction::isVersionChange() const
 {
     return m_transactionInfo.mode() == IndexedDB::TransactionMode::VersionChange;
index 5005f07..efa09f7 100644 (file)
@@ -64,6 +64,7 @@ public:
     IDBDatabaseInfo* originalDatabaseInfo() const;
 
     void abort();
+    void abortWithoutCallback();
     void commit();
 
     void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
index e41371c..fb57e3f 100644 (file)
@@ -369,6 +369,14 @@ void InProcessIDBServer::databaseConnectionClosed(uint64_t databaseConnectionIde
     });
 }
 
+void InProcessIDBServer::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
+{
+    RefPtr<InProcessIDBServer> self(this);
+    RunLoop::current().dispatch([this, self, databaseConnectionIdentifier, transactionIdentifier] {
+        m_server->abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
+    });
+}
+
 void InProcessIDBServer::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier)
 {
     RefPtr<InProcessIDBServer> self(this);
index fb7f660..103b7ca 100644 (file)
@@ -72,6 +72,7 @@ public:
     virtual void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count) override final;
     virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) override final;
     virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) override final;
+    virtual void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier) override final;
     virtual void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier) override final;
 
     // IDBConnectionToClient