Title: [191847] trunk
Revision
191847
Author
[email protected]
Date
2015-10-31 16:17:43 -0700 (Sat, 31 Oct 2015)

Log Message

storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html is flaky.
https://bugs.webkit.org/show_bug.cgi?id=150735

Reviewed by Darin Adler.

Source/WebCore:

No new tests (Covered by existing tests).

Transactions were liable to commit too early because IDBRequests could be waiting
to dispatch their error/success events but their operations would no longer be
registered with the transaction.

Having outstanding requests should also keep a transaction from committing, just
like having outstanding operations should.

* Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
(WebCore::IDBClient::IDBOpenDBRequest::onUpgradeNeeded):

* Modules/indexeddb/client/IDBRequestImpl.cpp:
(WebCore::IDBClient::IDBRequest::dispatchEvent):

* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::addRequest):
(WebCore::IDBClient::IDBTransaction::removeRequest):
(WebCore::IDBClient::IDBTransaction::operationTimerFired):
(WebCore::IDBClient::IDBTransaction::requestGetRecord):
(WebCore::IDBClient::IDBTransaction::requestClearObjectStore):
(WebCore::IDBClient::IDBTransaction::requestPutOrAdd):
(WebCore::IDBClient::IDBTransaction::operationDidComplete):
* Modules/indexeddb/client/IDBTransactionImpl.h:

* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::completed):

LayoutTests:

* platform/mac-wk1/TestExpectations: Reenable the test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191846 => 191847)


--- trunk/LayoutTests/ChangeLog	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/LayoutTests/ChangeLog	2015-10-31 23:17:43 UTC (rev 191847)
@@ -1,3 +1,12 @@
+2015-10-31  Brady Eidson  <[email protected]>
+
+        storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html is flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=150735
+
+        Reviewed by Darin Adler.
+
+        * platform/mac-wk1/TestExpectations: Reenable the test.
+
 2015-10-30  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (191846 => 191847)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-10-31 23:17:43 UTC (rev 191847)
@@ -50,8 +50,6 @@
 
 webkit.org/b/150564 svg/repaint/add-background-property-on-root.html [ Pass Timeout ]
 
-webkit.org/b/150735 storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html [ Pass Failure ]
-
 ### END OF (1) Failures with bug reports
 ########################################
 

Modified: trunk/Source/WebCore/ChangeLog (191846 => 191847)


--- trunk/Source/WebCore/ChangeLog	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/ChangeLog	2015-10-31 23:17:43 UTC (rev 191847)
@@ -1,3 +1,38 @@
+2015-10-31  Brady Eidson  <[email protected]>
+
+        storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html is flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=150735
+
+        Reviewed by Darin Adler.
+
+        No new tests (Covered by existing tests).
+
+        Transactions were liable to commit too early because IDBRequests could be waiting
+        to dispatch their error/success events but their operations would no longer be
+        registered with the transaction.
+        
+        Having outstanding requests should also keep a transaction from committing, just
+        like having outstanding operations should.
+        
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBOpenDBRequest::onUpgradeNeeded):
+        
+        * Modules/indexeddb/client/IDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBRequest::dispatchEvent):
+        
+        * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+        (WebCore::IDBClient::IDBTransaction::addRequest):
+        (WebCore::IDBClient::IDBTransaction::removeRequest):
+        (WebCore::IDBClient::IDBTransaction::operationTimerFired):
+        (WebCore::IDBClient::IDBTransaction::requestGetRecord):
+        (WebCore::IDBClient::IDBTransaction::requestClearObjectStore):
+        (WebCore::IDBClient::IDBTransaction::requestPutOrAdd):
+        (WebCore::IDBClient::IDBTransaction::operationDidComplete):
+        * Modules/indexeddb/client/IDBTransactionImpl.h:
+        
+        * Modules/indexeddb/client/TransactionOperation.h:
+        (WebCore::IDBClient::TransactionOperation::completed):
+
 2015-10-31  Philippe Normand  <[email protected]>
 
         [GStreamer][Mac] Fix WebAudio build

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp (191846 => 191847)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp	2015-10-31 23:17:43 UTC (rev 191847)
@@ -96,6 +96,7 @@
     m_result = IDBAny::create(WTF::move(database));
     m_readyState = IDBRequestReadyState::Done;
     m_transaction = adoptRef(&transaction.leakRef());
+    m_transaction->addRequest(*this);
 
     enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().upgradeneededEvent));
 }

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp (191846 => 191847)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp	2015-10-31 23:17:43 UTC (rev 191847)
@@ -166,6 +166,10 @@
 
     m_hasPendingActivity = false;
 
+    // FIXME: When we implement reusable requests (for cursors) it will be incorrect to always remove the request from the transaction.
+    if (m_transaction)
+        m_transaction->removeRequest(*this);
+
     return dontPreventDefault;
 }
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (191846 => 191847)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp	2015-10-31 23:17:43 UTC (rev 191847)
@@ -207,6 +207,18 @@
         || m_state == IndexedDB::TransactionState::Finished;
 }
 
+void IDBTransaction::addRequest(IDBRequest& request)
+{
+    ASSERT(!m_openRequests.contains(&request));
+    m_openRequests.add(&request);
+}
+
+void IDBTransaction::removeRequest(IDBRequest& request)
+{
+    ASSERT(m_openRequests.contains(&request));
+    m_openRequests.remove(&request);
+}
+
 void IDBTransaction::scheduleOperation(RefPtr<TransactionOperation>&& operation)
 {
     ASSERT(!m_transactionOperationMap.contains(operation->identifier()));
@@ -237,6 +249,9 @@
         return;
     }
 
+    if (!m_transactionOperationMap.isEmpty() || !m_openRequests.isEmpty())
+        return;
+
     if (!isFinishedOrFinishing())
         commit();
 }
@@ -393,6 +408,7 @@
     ASSERT(!keyRangeData.isNull);
 
     Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
 
     auto operation = createTransactionOperation(*this, request.get(), &IDBTransaction::didGetRecordOnServer, &IDBTransaction::getRecordOnServer, keyRangeData);
     scheduleOperation(WTF::move(operation));
@@ -421,6 +437,7 @@
     ASSERT(isActive());
 
     Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
 
     uint64_t objectStoreIdentifier = objectStore.info().identifier();
     auto operation = createTransactionOperation(*this, request.get(), &IDBTransaction::didClearObjectStoreOnServer, &IDBTransaction::clearObjectStoreOnServer, objectStoreIdentifier);
@@ -452,6 +469,7 @@
     ASSERT(objectStore.info().autoIncrement() || key);
 
     Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+    addRequest(request.get());
 
     auto operation = createTransactionOperation(*this, request.get(), &IDBTransaction::didPutOrAddOnServer, &IDBTransaction::putOrAddOnServer, key, &value, overwriteMode);
     scheduleOperation(WTF::move(operation));
@@ -503,6 +521,14 @@
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess);
 }
 
+void IDBTransaction::operationDidComplete(TransactionOperation& operation)
+{
+    ASSERT(m_transactionOperationMap.get(operation.identifier()) == &operation);
+    m_transactionOperationMap.remove(operation.identifier());
+
+    scheduleOperationTimer();
+}
+
 void IDBTransaction::establishOnServer()
 {
     LOG(IndexedDB, "IDBTransaction::establishOnServer");

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h (191846 => 191847)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h	2015-10-31 23:17:43 UTC (rev 191847)
@@ -95,12 +95,15 @@
 
     void deleteObjectStore(const String& objectStoreName);
 
+    void addRequest(IDBRequest&);
+    void removeRequest(IDBRequest&);
+
     IDBConnectionToServer& serverConnection();
 
     void activate();
     void deactivate();
 
-    void scheduleOperationTimer();
+    void operationDidComplete(TransactionOperation&);
 
 private:
     IDBTransaction(IDBDatabase&, const IDBTransactionInfo&);
@@ -138,6 +141,8 @@
 
     void establishOnServer();
 
+    void scheduleOperationTimer();
+
     Ref<IDBDatabase> m_database;
     IDBTransactionInfo m_info;
     std::unique_ptr<IDBDatabaseInfo> m_originalDatabaseInfo;
@@ -154,6 +159,8 @@
     HashMap<IDBResourceIdentifier, RefPtr<TransactionOperation>> m_transactionOperationMap;
 
     HashMap<String, RefPtr<IDBObjectStore>> m_referencedObjectStores;
+
+    HashSet<RefPtr<IDBRequest>> m_openRequests;
 };
 
 class TransactionActivator {

Modified: trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h (191846 => 191847)


--- trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h	2015-10-31 23:12:53 UTC (rev 191846)
+++ trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h	2015-10-31 23:17:43 UTC (rev 191847)
@@ -48,7 +48,7 @@
     void completed(const IDBResultData& data)
     {
         m_completeFunction(data);
-        m_transaction->scheduleOperationTimer();
+        m_transaction->operationDidComplete(*this);
     }
 
     const IDBResourceIdentifier& identifier() const { return m_identifier; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to