Title: [195784] trunk
Revision
195784
Author
beid...@apple.com
Date
2016-01-28 14:52:05 -0800 (Thu, 28 Jan 2016)

Log Message

Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.
https://bugs.webkit.org/show_bug.cgi?id=153614

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (A few failing tests pass, a few get closer).

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange): Call notifyCursorsOfChanges.
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Ditto.

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

* Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
(WebCore::IDBServer::SQLiteIDBTransaction::maybeOpenBackingStoreCursor): Remember these transient backing
  store cursors so they can be notified of changes.
(WebCore::IDBServer::SQLiteIDBTransaction::closeCursor): Handle removing the cursor from the right set.
(WebCore::IDBServer::SQLiteIDBTransaction::notifyCursorsOfChanges):
* Modules/indexeddb/server/SQLiteIDBTransaction.h:

LayoutTests:

* platform/mac-wk1/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195783 => 195784)


--- trunk/LayoutTests/ChangeLog	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/LayoutTests/ChangeLog	2016-01-28 22:52:05 UTC (rev 195784)
@@ -1,5 +1,14 @@
 2016-01-28  Brady Eidson  <beid...@apple.com>
 
+        Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.
+        https://bugs.webkit.org/show_bug.cgi?id=153614
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+
+2016-01-28  Brady Eidson  <beid...@apple.com>
+
         Modern IDB: SQLite backend doesn't support deleting ranges with more than one key.
         https://bugs.webkit.org/show_bug.cgi?id=153604
 

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195783 => 195784)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-28 22:52:05 UTC (rev 195784)
@@ -461,8 +461,6 @@
 storage/indexeddb/modern/cursor-7.html [ Failure ]
 storage/indexeddb/modern/get-keyrange.html [ Failure ]
 storage/indexeddb/modern/index-3.html [ Failure ]
-storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
-storage/indexeddb/mozilla/cursors.html [ Failure ]
 storage/indexeddb/objectstore-autoincrement.html [ Failure ]
 
 # SQLite backend tests that timeout

Modified: trunk/Source/WebCore/ChangeLog (195783 => 195784)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 22:52:05 UTC (rev 195784)
@@ -1,5 +1,30 @@
 2016-01-28  Brady Eidson  <beid...@apple.com>
 
+        Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.
+        https://bugs.webkit.org/show_bug.cgi?id=153614
+
+        Reviewed by Alex Christensen.
+
+        No new tests (A few failing tests pass, a few get closer).
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange): Call notifyCursorsOfChanges.
+        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Ditto.
+
+        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+        (WebCore::IDBServer::SQLiteIDBCursor::SQLiteIDBCursor):
+        (WebCore::IDBServer::SQLiteIDBCursor::~SQLiteIDBCursor):
+        * Modules/indexeddb/server/SQLiteIDBCursor.h:
+
+        * Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
+        (WebCore::IDBServer::SQLiteIDBTransaction::maybeOpenBackingStoreCursor): Remember these transient backing 
+          store cursors so they can be notified of changes.
+        (WebCore::IDBServer::SQLiteIDBTransaction::closeCursor): Handle removing the cursor from the right set.
+        (WebCore::IDBServer::SQLiteIDBTransaction::notifyCursorsOfChanges):
+        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
+
+2016-01-28  Brady Eidson  <beid...@apple.com>
+
         Modern IDB: SQLite backend doesn't support deleting ranges with more than one key.
         https://bugs.webkit.org/show_bug.cgi?id=153604
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (195783 => 195784)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-28 22:52:05 UTC (rev 195784)
@@ -1055,6 +1055,8 @@
         }
     }
 
+    transaction->notifyCursorsOfChanges(objectStoreID);
+
     return error;
 }
 
@@ -1144,6 +1146,8 @@
 
     // FIXME: If there was an error indexing this record, remove it.
 
+    transaction->notifyCursorsOfChanges(objectStoreInfo.identifier());
+
     return error;
 }
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (195783 => 195784)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-01-28 22:52:05 UTC (rev 195784)
@@ -83,10 +83,17 @@
     , m_indexID(indexID ? indexID : IDBIndexMetadata::InvalidId)
     , m_cursorDirection(IndexedDB::CursorDirection::Next)
     , m_keyRange(range)
+    , m_backingStoreCursor(true)
 {
     ASSERT(m_objectStoreID);
 }
 
+SQLiteIDBCursor::~SQLiteIDBCursor()
+{
+    if (m_backingStoreCursor)
+        m_transaction->closeCursor(*this);
+}
+
 void SQLiteIDBCursor::currentData(IDBGetResult& result)
 {
     if (m_completed) {

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h (195783 => 195784)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h	2016-01-28 22:52:05 UTC (rev 195784)
@@ -52,6 +52,8 @@
     SQLiteIDBCursor(SQLiteIDBTransaction&, const IDBCursorInfo&);
     SQLiteIDBCursor(SQLiteIDBTransaction&, uint64_t objectStoreID, uint64_t indexID, const IDBKeyRangeData&);
 
+    ~SQLiteIDBCursor();
+
     const IDBResourceIdentifier& identifier() const { return m_cursorIdentifier; }
     SQLiteIDBTransaction* transaction() const { return m_transaction; }
 
@@ -109,6 +111,8 @@
 
     bool m_completed { false };
     bool m_errored { false };
+
+    bool m_backingStoreCursor { false };
 };
 
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp (195783 => 195784)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp	2016-01-28 22:52:05 UTC (rev 195784)
@@ -104,7 +104,12 @@
     ASSERT(m_sqliteTransaction);
     ASSERT(m_sqliteTransaction->inProgress());
 
-    return SQLiteIDBCursor::maybeCreateBackingStoreCursor(*this, objectStoreID, indexID, range);
+    auto cursor = SQLiteIDBCursor::maybeCreateBackingStoreCursor(*this, objectStoreID, indexID, range);
+
+    if (cursor)
+        m_backingStoreCursors.add(cursor.get());
+
+    return cursor;
 }
 
 SQLiteIDBCursor* SQLiteIDBTransaction::maybeOpenCursor(const IDBCursorInfo& info)
@@ -128,6 +133,12 @@
 
 void SQLiteIDBTransaction::closeCursor(SQLiteIDBCursor& cursor)
 {
+    auto backingStoreTake = m_backingStoreCursors.take(&cursor);
+    if (backingStoreTake) {
+        ASSERT(!m_cursors.contains(cursor.identifier()));
+        return;
+    }
+
     ASSERT(m_cursors.contains(cursor.identifier()));
 
     m_backingStore.unregisterCursor(cursor);
@@ -140,6 +151,11 @@
         if (i.value->objectStoreID() == objectStoreID)
             i.value->objectStoreRecordsChanged();
     }
+
+    for (auto* cursor : m_backingStoreCursors) {
+        if (cursor->objectStoreID() == objectStoreID)
+            cursor->objectStoreRecordsChanged();
+    }
 }
 
 void SQLiteIDBTransaction::clearCursors()

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h (195783 => 195784)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2016-01-28 22:40:02 UTC (rev 195783)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2016-01-28 22:52:05 UTC (rev 195784)
@@ -33,6 +33,7 @@
 #include "IDBTransactionInfo.h"
 #include "IndexedDB.h"
 #include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {
@@ -79,6 +80,7 @@
     SQLiteIDBBackingStore& m_backingStore;
     std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
     HashMap<IDBResourceIdentifier, std::unique_ptr<SQLiteIDBCursor>> m_cursors;
+    HashSet<SQLiteIDBCursor*> m_backingStoreCursors;
 };
 
 } // namespace IDBServer
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to