Bug 103536

Summary: IndexedDB: Simplify IDBTransactionBackendImpl::scheduleTask usage
Product: WebKit Reporter: Joshua Bell <jsbell>
Component: WebCore Misc.Assignee: Joshua Bell <jsbell>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, alecflett, dglazkov, dgrogan, fishd, jamesr, tkent+wkapi, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Joshua Bell
Reported 2012-11-28 10:17:30 PST
Currently it returns true/false but we eventually drop the return type on the floor.
Attachments
Patch (31.90 KB, patch)
2012-11-29 12:28 PST, Joshua Bell
no flags
Patch (29.57 KB, patch)
2012-11-30 15:30 PST, Joshua Bell
no flags
Patch (29.66 KB, patch)
2012-12-03 16:37 PST, Joshua Bell
no flags
Patch (29.96 KB, patch)
2012-12-04 09:02 PST, Joshua Bell
no flags
Patch (27.96 KB, patch)
2012-12-06 12:06 PST, Joshua Bell
no flags
Patch (20.15 KB, patch)
2013-01-02 15:27 PST, Joshua Bell
no flags
Patch (20.13 KB, patch)
2013-01-02 17:13 PST, Joshua Bell
no flags
Alec Flett
Comment 1 2012-11-28 10:32:28 PST
which function?
Joshua Bell
Comment 2 2012-11-28 10:33:15 PST
Whoops - scheduleTask. Fixed title.
Joshua Bell
Comment 3 2012-11-29 12:28:53 PST
Joshua Bell
Comment 4 2012-11-29 12:31:07 PST
So hrm. Two reasons this can't be all glorious cleanup: * The schema change methods (create/delete ObjectStore/Index) are still synchronous and return exception codes. * The other (async) calls rely on callback->onError(ABORT_ERR) to clean up internal callback tracking inside Chromium, even though the AbortError actually gets generated on the front end.
Joshua Bell
Comment 5 2012-11-30 15:30:58 PST
Joshua Bell
Comment 6 2012-11-30 15:33:23 PST
So this patch doesn't actually simplify anything; I'm going to punt on it for now. An alternate approach might be to optionally pass the IDBCallback into scheduleTask, and have scheduleTask() responsible for calling callbacks->onError(), which would take care of most of the cases.
Joshua Bell
Comment 7 2012-12-03 15:51:14 PST
Or have the WebIDBCallbacksProxy destructor call onError if it never fired onSuccess/onError - that's probably the best approach.
Joshua Bell
Comment 8 2012-12-03 16:37:08 PST
Joshua Bell
Comment 9 2012-12-03 16:38:04 PST
I took another stab at this, making chromium clean up itself. Still not sure this is worth it, but I'm liking it more.
WebKit Review Bot
Comment 10 2012-12-03 16:38:54 PST
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
David Grogan
Comment 11 2012-12-03 17:11:20 PST
Comment on attachment 177368 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=177368&action=review > Source/WebCore/ChangeLog:9 > + back-end after an asynchronous transaction abort out of WebCore, since the Asynchronous transaction abort == one that was initiated by code in the browser process, not by script? > Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp:62 > + m_callbacks->onError(WebIDBDatabaseError(WebIDBDatabaseExceptionAbortError, WebString())); This just calls IDBRequest::onError without going through chrome code, doesn't it? Was this supposed to go in IDBCallbacksProxy?
Joshua Bell
Comment 12 2012-12-03 17:23:51 PST
(In reply to comment #11) > (From update of attachment 177368 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=177368&action=review > > > Source/WebCore/ChangeLog:9 > > + back-end after an asynchronous transaction abort out of WebCore, since the > > Asynchronous transaction abort == one that was initiated by code in the browser process, not by script? Correct. The scenario is that there are requests in-flight from the front end via async IPC when the back-end decides to abort. > > Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp:62 > > + m_callbacks->onError(WebIDBDatabaseError(WebIDBDatabaseExceptionAbortError, WebString())); > > This just calls IDBRequest::onError without going through chrome code, doesn't it? Was this supposed to go in IDBCallbacksProxy? q *sigh* Yes, thanks.
Joshua Bell
Comment 13 2012-12-04 09:02:16 PST
David Grogan
Comment 14 2012-12-04 15:31:38 PST
Comment on attachment 177497 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=177497&action=review LGTM > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:260 > ec = IDBDatabaseException::TransactionInactiveError; Could you add a FIXME to add a test for this clause? It seems like it would be hard to test without flakiness. > Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:514 > ec = IDBDatabaseException::TransactionInactiveError; Could you add a FIXME to add a test for this clause? > Source/WebKit/chromium/src/IDBCallbacksProxy.cpp:69 > + // This cleans up the request's IPC id. To test this, I suppose you'd need a browser test that loaded up a page that tries to trigger this scenario (backend aborts while there was an in-flight request from the frontend) many times. Then the browser test code would retrieve the IndexedDBDispatcherHost and check its maps for residual callbacks entries. Seems like you wouldn't be able to guarantee that the page triggered this scenario. Or we could let the valgrind bots run our layout tests in content_shell and see if we get any reports. I don't know if stray map entries is something valgrind would catch though. Any other options you've thought of? If you haven't come up with something better I'd say just add a FIXME noting that this has no test.
Joshua Bell
Comment 15 2012-12-06 12:06:39 PST
Joshua Bell
Comment 16 2012-12-06 12:10:01 PST
(In reply to comment #15) > Created an attachment (id=178054) [details] > Patch (Just a rebase, I haven't addressed the above comments yet)
Joshua Bell
Comment 17 2013-01-02 15:27:25 PST
Joshua Bell
Comment 18 2013-01-02 15:29:12 PST
Revised the patch to remove the need to explicitly test transaction->isFinished() before calling scheduleTask(), and have the latter still return a success flag. This streamlines the code and is less likely to lead to flaky bugs in the future where a dev adds a scheduleTask() call without checking. dgrogan@, alecflett@ - one more look?
David Grogan
Comment 19 2013-01-02 16:08:15 PST
lgtm except that the bug title is now inaccurate.
Joshua Bell
Comment 20 2013-01-02 16:09:32 PST
(In reply to comment #19) > lgtm except that the bug title is now inaccurate. Hah, will fix. :)
Joshua Bell
Comment 21 2013-01-02 17:13:10 PST
Joshua Bell
Comment 22 2013-01-02 17:14:50 PST
abarth@ - r? for the trivial Chromium public API change? tony@ - r? overall?
Adam Barth
Comment 23 2013-01-02 17:17:26 PST
Comment on attachment 181116 [details] Patch API change LGTM
Alec Flett
Comment 24 2013-01-02 17:19:38 PST
Comment on attachment 181116 [details] Patch any reason scheduleTask can't now return void as you originally tried?
Alec Flett
Comment 25 2013-01-02 17:21:13 PST
oh wait comment 4..
Joshua Bell
Comment 26 2013-01-02 17:23:43 PST
(In reply to comment #25) > oh wait comment 4.. Yep. :) Once {create,delete}{ObjectStore,Index} are async we can probably simplify further.
WebKit Review Bot
Comment 27 2013-01-03 10:25:14 PST
Comment on attachment 181116 [details] Patch Clearing flags on attachment: 181116 Committed r138716: <http://trac.webkit.org/changeset/138716>
WebKit Review Bot
Comment 28 2013-01-03 10:25:20 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.