Changeset 192749 in webkit
- Timestamp:
- Nov 23, 2015, 11:48:50 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r192748 r192749 1 2015-11-23 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: When a transaction is aborted, call onerror handlers for all in-progress requests. 4 https://bugs.webkit.org/show_bug.cgi?id=151550 5 6 Reviewed by Alex Christensen. 7 8 * storage/indexeddb/modern/abort-requests-cancelled-expected.txt: Added. 9 * storage/indexeddb/modern/abort-requests-cancelled.html: Added. 10 * storage/indexeddb/modern/idbtransaction-objectstore-failures-expected.txt: 11 * storage/indexeddb/modern/idbtransaction-objectstore-failures.html: 12 * storage/indexeddb/modern/index-5-expected.txt: 13 * storage/indexeddb/modern/index-5.html: 14 1 15 2015-11-23 Brady Eidson <beidson@apple.com> 2 16 -
trunk/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstore-failures-expected.txt
r191645 r192749 6 6 ALERT: Caught attempt to access non-existant object store on the transaction 7 7 ALERT: Caught attempt to access valid object store on a transaction that is already finishing 8 ALERT: First version change transaction abort 8 ALERT: put failed (because transaction was aborted) 9 ALERT: First version change transaction unexpected error - [object Event] 9 10 ALERT: Done 10 11 This tests some obvious failures that can happen while calling transaction.objectStore() -
trunk/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstore-failures.html
r191645 r192749 31 31 var putRequest = os1.put("bar", "foo"); 32 32 33 putRequest.onerror = function(event) { 34 alert("put unexpectedly failed - " + event); 35 done(); 33 putRequest.onerror = function() { 34 alert("put failed (because transaction was aborted)"); 36 35 } 37 36 -
trunk/LayoutTests/storage/indexeddb/modern/index-5-expected.txt
r192618 r192749 2 2 (The index creation should fail). 3 3 Initial upgrade needed: Old version - 0 New version - 1 4 Error getting cursor count 5 Error opening or iterating cursor 4 6 Initial upgrade versionchange transaction aborted (expected because index creation failed, and that should've caused transaction abort) 5 7 Done -
trunk/LayoutTests/storage/indexeddb/modern/index-5.html
r192618 r192749 30 30 log("Count is: " + countRequest.result); 31 31 } 32 countRequest.onerror = function(e) { 33 log("Error getting cursor count"); 34 e.stopPropagation(); 35 } 32 36 33 37 var cursorRequest = index.openCursor(); … … 42 46 } 43 47 cursorRequest.onerror = function(e) { 44 log("Unexpected error opening or iterating cursor"); 45 logCursor(cursorRequest.result); 46 done(); 48 log("Error opening or iterating cursor"); 49 e.stopPropagation(); 47 50 } 48 51 } -
trunk/Source/WebCore/ChangeLog
r192748 r192749 1 2015-11-23 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: When a transaction is aborted, call onerror handlers for all in-progress requests. 4 https://bugs.webkit.org/show_bug.cgi?id=151550 5 6 Reviewed by Alex Christensen. 7 8 Test: storage/indexeddb/modern/abort-requests-cancelled.html 9 storage/indexeddb/modern/idbtransaction-objectstore-failures.html (with changes) 10 storage/indexeddb/modern/index-5.html (with changes) 11 Various (currently skipped) legacy IDB tests. 12 13 * Modules/indexeddb/client/IDBDatabaseImpl.cpp: 14 (WebCore::IDBClient::IDBDatabase::transaction): 15 (WebCore::IDBClient::IDBDatabase::startVersionChangeTransaction): 16 (WebCore::IDBClient::IDBDatabase::didStartTransaction): 17 (WebCore::IDBClient::IDBDatabase::willCommitTransaction): 18 (WebCore::IDBClient::IDBDatabase::didCommitTransaction): 19 (WebCore::IDBClient::IDBDatabase::willAbortTransaction): 20 (WebCore::IDBClient::IDBDatabase::didAbortTransaction): 21 (WebCore::IDBClient::IDBDatabase::didCommitOrAbortTransaction): 22 23 * Modules/indexeddb/client/IDBTransactionImpl.cpp: 24 (WebCore::IDBClient::IDBTransaction::abort): 25 (WebCore::IDBClient::IDBTransaction::abortOnServerAndCancelRequests): 26 (WebCore::IDBClient::IDBTransaction::didCreateObjectStoreOnServer): 27 (WebCore::IDBClient::IDBTransaction::didCreateIndexOnServer): 28 (WebCore::IDBClient::IDBTransaction::didGetRecordOnServer): 29 (WebCore::IDBClient::IDBTransaction::didDeleteObjectStoreOnServer): 30 (WebCore::IDBClient::IDBTransaction::didDeleteIndexOnServer): 31 (WebCore::IDBClient::IDBTransaction::immediateAbort): Deleted. 32 (WebCore::IDBClient::IDBTransaction::abortOnServer): Deleted. 33 * Modules/indexeddb/client/IDBTransactionImpl.h: 34 35 * Modules/indexeddb/server/MemoryIDBBackingStore.cpp: 36 (WebCore::IDBServer::MemoryIDBBackingStore::abortTransaction): 37 (WebCore::IDBServer::MemoryIDBBackingStore::commitTransaction): 38 39 * Modules/indexeddb/shared/IDBError.cpp: 40 (WebCore::idbErrorName): 41 (WebCore::idbErrorDescription): 42 * Modules/indexeddb/shared/IDBError.h: 43 44 * Modules/indexeddb/shared/IDBResourceIdentifier.cpp: 45 (WebCore::IDBResourceIdentifier::loggingString): 46 * Modules/indexeddb/shared/IDBResourceIdentifier.h: 47 1 48 2015-11-23 Brady Eidson <beidson@apple.com> 2 49 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp
r192748 r192749 172 172 auto transaction = IDBTransaction::create(*this, info); 173 173 174 LOG(IndexedDB, "IDBDatabase::transaction - Added active transaction %s", info.identifier().loggingString().utf8().data()); 175 174 176 m_activeTransactions.set(info.identifier(), &transaction.get()); 175 177 … … 242 244 Ref<IDBTransaction> IDBDatabase::startVersionChangeTransaction(const IDBTransactionInfo& info, IDBOpenDBRequest& request) 243 245 { 244 LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction ");246 LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction %s", info.identifier().loggingString().utf8().data()); 245 247 246 248 ASSERT(!m_versionChangeTransaction); … … 257 259 void IDBDatabase::didStartTransaction(IDBTransaction& transaction) 258 260 { 259 LOG(IndexedDB, "IDBDatabase::didStartTransaction ");261 LOG(IndexedDB, "IDBDatabase::didStartTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 260 262 ASSERT(!m_versionChangeTransaction); 261 263 264 // It is possible for the client to have aborted a transaction before the server replies back that it has started. 265 if (m_abortingTransactions.contains(transaction.info().identifier())) 266 return; 267 262 268 m_activeTransactions.set(transaction.info().identifier(), &transaction); 263 269 } … … 265 271 void IDBDatabase::willCommitTransaction(IDBTransaction& transaction) 266 272 { 267 LOG(IndexedDB, "IDBDatabase::willCommitTransaction ");273 LOG(IndexedDB, "IDBDatabase::willCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 268 274 269 275 auto refTransaction = m_activeTransactions.take(transaction.info().identifier()); … … 274 280 void IDBDatabase::didCommitTransaction(IDBTransaction& transaction) 275 281 { 276 LOG(IndexedDB, "IDBDatabase::didCommitTransaction ");282 LOG(IndexedDB, "IDBDatabase::didCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 277 283 278 284 if (m_versionChangeTransaction == &transaction) … … 284 290 void IDBDatabase::willAbortTransaction(IDBTransaction& transaction) 285 291 { 286 LOG(IndexedDB, "IDBDatabase::willAbortTransaction ");292 LOG(IndexedDB, "IDBDatabase::willAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 287 293 288 294 auto refTransaction = m_activeTransactions.take(transaction.info().identifier()); … … 293 299 void IDBDatabase::didAbortTransaction(IDBTransaction& transaction) 294 300 { 295 LOG(IndexedDB, "IDBDatabase::didAbortTransaction ");301 LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 296 302 297 303 if (transaction.isVersionChange()) { … … 305 311 void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction) 306 312 { 307 LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction ");313 LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data()); 308 314 309 315 if (m_versionChangeTransaction == &transaction) -
trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp
r192720 r192749 166 166 } 167 167 168 void IDBTransaction::immediateAbort() 169 { 170 LOG(IndexedDB, "IDBTransaction::immediateAbort"); 171 172 if (isFinishedOrFinishing()) 173 return; 168 void IDBTransaction::abort(ExceptionCode& ec) 169 { 170 LOG(IndexedDB, "IDBTransaction::abort"); 171 172 if (isFinishedOrFinishing()) { 173 ec = INVALID_STATE_ERR; 174 return; 175 } 174 176 175 177 m_state = IndexedDB::TransactionState::Aborting; 176 178 m_database->willAbortTransaction(*this); 177 179 178 auto operation = createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServer); 179 abortOnServer(*operation); 180 } 181 182 void IDBTransaction::abort(ExceptionCode& ec) 183 { 184 LOG(IndexedDB, "IDBTransaction::abort"); 185 186 if (isFinishedOrFinishing()) { 187 ec = INVALID_STATE_ERR; 188 return; 189 } 190 191 m_state = IndexedDB::TransactionState::Aborting; 192 m_database->willAbortTransaction(*this); 193 194 auto operation = createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServer); 195 scheduleOperation(WTF::move(operation)); 196 } 197 198 void IDBTransaction::abortOnServer(TransactionOperation&) 199 { 200 LOG(IndexedDB, "IDBTransaction::abortOnServer"); 180 m_abortQueue.swap(m_transactionOperationQueue); 181 182 auto operation = createTransactionOperation(*this, nullptr, &IDBTransaction::abortOnServerAndCancelRequests); 183 scheduleOperation(WTF::move(operation)); 184 } 185 186 void IDBTransaction::abortOnServerAndCancelRequests(TransactionOperation&) 187 { 188 LOG(IndexedDB, "IDBTransaction::abortOnServerAndCancelRequests"); 189 190 ASSERT(m_transactionOperationQueue.isEmpty()); 191 201 192 serverConnection().abortTransaction(*this); 193 194 IDBError error(IDBExceptionCode::AbortError); 195 for (auto& operation : m_abortQueue) 196 operation->completed(IDBResultData::error(operation->identifier(), error)); 197 198 // Since we're aborting, this abortOnServerAndCancelRequests() operation should be the only 199 // in-progress operation, and it should be impossible to have queued any further operations. 200 ASSERT(m_transactionOperationMap.size() == 1); 201 ASSERT(m_transactionOperationQueue.isEmpty()); 202 202 } 203 203 … … 427 427 LOG(IndexedDB, "IDBTransaction::didCreateObjectStoreOnServer"); 428 428 429 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess );429 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error); 430 430 } 431 431 … … 459 459 return; 460 460 461 // If index creation failed, the transaction is aborted. 462 immediateAbort(); 461 ASSERT(resultData.type() == IDBResultType::Error); 462 463 // This operation might have failed because the transaction is already aborting. 464 if (m_state == IndexedDB::TransactionState::Aborting) 465 return; 466 467 // Otherwise, failure to create an index forced abortion of the transaction. 468 ExceptionCode ec; 469 abort(ec); 463 470 } 464 471 … … 585 592 { 586 593 LOG(IndexedDB, "IDBTransaction::didGetRecordOnServer"); 594 595 if (resultData.type() == IDBResultType::Error) { 596 request.requestCompleted(resultData); 597 return; 598 } 599 600 ASSERT(resultData.type() == IDBResultType::GetRecordSuccess); 587 601 588 602 const IDBGetResult& result = resultData.getResult(); … … 761 775 { 762 776 LOG(IndexedDB, "IDBTransaction::didDeleteObjectStoreOnServer"); 763 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess );777 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess || resultData.type() == IDBResultType::Error); 764 778 } 765 779 … … 785 799 { 786 800 LOG(IndexedDB, "IDBTransaction::didDeleteIndexOnServer"); 787 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteIndexSuccess );801 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteIndexSuccess || resultData.type() == IDBResultType::Error); 788 802 } 789 803 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h
r192748 r192749 143 143 144 144 void commitOnServer(TransactionOperation&); 145 void abortOnServer (TransactionOperation&);145 void abortOnServerAndCancelRequests(TransactionOperation&); 146 146 147 147 void createObjectStoreOnServer(TransactionOperation&, const IDBObjectStoreInfo&); … … 183 183 void scheduleOperationTimer(); 184 184 185 void immediateAbort();186 187 185 Ref<IDBDatabase> m_database; 188 186 IDBTransactionInfo m_info; … … 200 198 201 199 Deque<RefPtr<TransactionOperation>> m_transactionOperationQueue; 200 Deque<RefPtr<TransactionOperation>> m_abortQueue; 202 201 HashMap<IDBResourceIdentifier, RefPtr<TransactionOperation>> m_transactionOperationMap; 203 202 -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
r192645 r192749 96 96 IDBError MemoryIDBBackingStore::abortTransaction(const IDBResourceIdentifier& transactionIdentifier) 97 97 { 98 LOG(IndexedDB, "MemoryIDBBackingStore::abortTransaction ");98 LOG(IndexedDB, "MemoryIDBBackingStore::abortTransaction - %s", transactionIdentifier.loggingString().utf8().data()); 99 99 100 100 auto transaction = m_transactions.take(transactionIdentifier); … … 109 109 IDBError MemoryIDBBackingStore::commitTransaction(const IDBResourceIdentifier& transactionIdentifier) 110 110 { 111 LOG(IndexedDB, "MemoryIDBBackingStore::commitTransaction ");111 LOG(IndexedDB, "MemoryIDBBackingStore::commitTransaction - %s", transactionIdentifier.loggingString().utf8().data()); 112 112 113 113 auto transaction = m_transactions.take(transactionIdentifier); -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBError.cpp
r191635 r192749 68 68 return entry; 69 69 } 70 case IDBExceptionCode::AbortError: { 71 static NeverDestroyed<String> entry = ASCIILiteral("AbortError"); 72 return entry; 73 } 70 74 case IDBExceptionCode::None: 71 75 RELEASE_ASSERT_NOT_REACHED(); … … 108 112 case IDBExceptionCode::DataCloneError: { 109 113 static NeverDestroyed<String> entry = ASCIILiteral("Data being stored could not be cloned by the structured cloning algorithm."); 114 return entry; 115 } 116 case IDBExceptionCode::AbortError: { 117 static NeverDestroyed<String> entry = ASCIILiteral("Transaction was aborted"); 110 118 return entry; 111 119 } -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBError.h
r191635 r192749 45 45 InvalidStateError, 46 46 DataCloneError, 47 AbortError, 47 48 }; 48 49 -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp
r191114 r192749 95 95 } 96 96 97 #ifndef NDEBUG 98 String IDBResourceIdentifier::loggingString() const 99 { 100 return String::format("<%" PRIu64", %" PRIu64">", m_idbConnectionIdentifier, m_resourceNumber); 101 } 102 #endif 97 103 } // namespace WebCore 98 104 -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h
r191114 r192749 73 73 IDBResourceIdentifier isolatedCopy() const; 74 74 75 #ifndef NDEBUG 76 String loggingString() const; 77 #endif 78 75 79 private: 76 80 IDBResourceIdentifier() = delete;
Note:
See TracChangeset
for help on using the changeset viewer.