IndexedDB: error in starting version change transaction may be neglected
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2019 18:06:09 +0000 (18:06 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2019 18:06:09 +0000 (18:06 +0000)
commitee3065ac9a906ecfdc93d7be8bbc7854ad1a091a
treeb2f973ae50b12c8ecfdd7759d665af5451ec66a0
parent6aefa6570e6fdac5661efe790866e718e8b0e357
IndexedDB: error in starting version change transaction may be neglected
https://bugs.webkit.org/show_bug.cgi?id=199818
<rdar://problem/52925738>

Reviewed by Brady Eidson.

For version change transaction, IDBServer didn't wait the result of beginTransaction on the background thread
before giving the IDBClient the result of open request. In this case, beginTransaction may fail to update the
DatabaseVersion in database file or set m_originalDatabaseInfoBeforeVersionChange, but the transaction was
marked as started. When we later set m_databaseInfo with m_originalDatabaseInfoBeforeVersionChange,
m_databaseInfo could become nullptr.

To write a test for this, we will need to simulate an SQLite error. I manually tested this by crafting the
SQLiteStatement in beginTransaction, making it an invalid statement, and verified that error event, instead of
ungradeneeded event is dispatched to the IDBRequest.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::startVersionChangeTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::performStartVersionChangeTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformStartVersionChangeTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete):
(WebCore::IDBServer::UniqueIDBDatabase::beginTransactionInBackingStore): Deleted.
* Modules/indexeddb/server/UniqueIDBDatabase.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h