Bug 143126 - IndexedDB: index creation fails after multiple versionchange events
Summary: IndexedDB: index creation fails after multiple versionchange events
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2015-03-26 21:00 PDT by Taylor Buley
Modified: 2016-06-01 15:21 PDT (History)
3 users (show)

See Also:

some IDB js to run in console (2.66 KB, text/javascript)
2015-03-26 21:00 PDT, Taylor Buley
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Taylor Buley 2015-03-26 21:00:58 PDT
Created attachment 249548 [details]
some IDB js to run in console

Background: I've found it challenging to keep IDB database connections open for reuse and have instead come to adopt a pattern where every open connection is closed after a single transaction (such as creating an object store or index) has been committed and fired its `complete` event. This is somewhat unorthodox compared to common patterns of reuse seen on the web but my IDB library is very old and time has told me this is the sanest approach when dealing with multiple tabs, etc. As a result, my typical "install code" chains together a number of consecutive `versionchange` transactions, one to create the database and one for each store and index.

I've been having trouble creating indexes in iOS8. The problem I see is that my indexes all create fine and and the transactions commit successfully as well but after all is said and done only the index for the last transaction to commit is available on the object store.

Attempting to create a test case for this, I've managed to cobble together something that throws an interesting error in WKWebViews in iOS 8.2 after a couple `versionchange` events. The expected result, confirmed as successful in recent Chrome and Firefox builds, would be a database on version `3` with an object store and two indexes. Instead, in the WKWebView a `NotFoundError` is thrown: "DOM IDBDatabase Exception 8: An operation failed because the requested database object could not be found."

The console.logs show this database as existing and on the correct version number prior to a failed opening after the second `versionchange`. I'm not sure it's exactly the issue I was attempting to document, but it seems at least related as it also appears for me when creating indexes after multiple `versionchange` events.

Comment 1 Radar WebKit Bug Importer 2015-04-25 14:59:21 PDT
Comment 2 Brady Eidson 2016-06-01 15:21:51 PDT
This should be working fine with modern IDB.

Please try in a WebKit nightly or Safari Tech Preview.