Bug 90822

Summary: IndexedDB: deleteDatabase fails if transaction running in other database
Product: WebKit Reporter: Joshua Bell <jsbell>
Component: WebCore Misc.Assignee: Joshua Bell <jsbell>
Status: RESOLVED FIXED    
Severity: Normal CC: alecflett, dgrogan, jochen, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Joshua Bell 2012-07-09 14:12:04 PDT
If a transaction is running in any database when deleteDatabase() is called, an error event will be fired at the IDBVersionChangeRequest and the delete will fail.

At the start of IDBLevelDBBackingStore.cpp there's a test:

if (m_currentTransaction) return false;

This guards against the deleteDatabase() logic which creates a transaction for the deletion itself - most of the WebKit IDB implementation is currently predicated on only one transaction running at a time. However, nothing outside of the IDBLevelDBBackingStore code treats the delete request as requiring a transaction, so it doesn't defer the delete until there are no transactions against any database.

It *should* be safe to allow the IDBLevelDBBackingStore::deleteDatabase() call to run even if there is another transaction running since there will be no overlap in key ranges, as long as m_currentTransaction is either not modified or is restored afterwards.
Comment 1 Joshua Bell 2012-07-09 14:25:55 PDT
Created attachment 151319 [details]
Patch
Comment 2 Joshua Bell 2012-07-09 14:27:01 PDT
dgrogan@, alecflett@ - take a look?
Comment 3 Joshua Bell 2012-07-09 14:28:49 PDT
+jochen@, in case he remembers a reason it wasn't done like this in the first place.
Comment 4 David Grogan 2012-07-09 14:37:11 PDT
Comment on attachment 151319 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=151319&action=review

Interested to see if Jochen remembers anything. Not like he's been busy since or anything :)

> LayoutTests/storage/indexeddb/deletedatabase-transaction.html:39
> +  request.onerror = unexpectedErrorCallback;

Could you add request.onblocked = unexpectedBlockedCallback ?
Comment 5 jochen 2012-07-09 14:55:52 PDT
Comment on attachment 151319 [details]
Patch

IIRC a prior version of the patch used some methods that just used the default transaction. That patch looks good

View in context: https://bugs.webkit.org/attachment.cgi?id=151319&action=review

> LayoutTests/storage/indexeddb/deletedatabase-transaction.html:31
> +  debug("");

nit. indent 4 spaces
Comment 6 Joshua Bell 2012-07-09 16:29:24 PDT
Created attachment 151349 [details]
Patch
Comment 7 Joshua Bell 2012-07-09 16:37:17 PDT
Created attachment 151352 [details]
Patch
Comment 8 Joshua Bell 2012-07-09 16:38:14 PDT
(In reply to comment #4)
> Could you add request.onblocked = unexpectedBlockedCallback ?

Done.

(In reply to comment #5)
> nit. indent 4 spaces

Fixed.

tony@ - r?
Comment 9 WebKit Review Bot 2012-07-09 18:46:54 PDT
Comment on attachment 151352 [details]
Patch

Clearing flags on attachment: 151352

Committed r122179: <http://trac.webkit.org/changeset/122179>
Comment 10 WebKit Review Bot 2012-07-09 18:46:59 PDT
All reviewed patches have been landed.  Closing bug.