RESOLVED CONFIGURATION CHANGED105559
IndexedDB: IDBOpenDBRequest sometimes receives two blocked events
https://bugs.webkit.org/show_bug.cgi?id=105559
Summary IndexedDB: IDBOpenDBRequest sometimes receives two blocked events
Joshua Bell
Reported 2012-12-20 11:47:58 PST
IndexedDB: IDBOpenDBRequest sometimes receives two blocked events
Attachments
Repro layout test (4.60 KB, patch)
2012-12-20 11:48 PST, Joshua Bell
no flags
Patch (29.21 KB, patch)
2012-12-20 16:48 PST, Joshua Bell
no flags
Patch (25.74 KB, patch)
2012-12-21 16:24 PST, Joshua Bell
no flags
Patch (24.99 KB, patch)
2013-02-12 14:33 PST, Joshua Bell
no flags
Patch (24.93 KB, patch)
2013-03-11 14:06 PDT, Joshua Bell
no flags
Patch (24.33 KB, patch)
2013-04-01 13:14 PDT, Joshua Bell
no flags
Joshua Bell
Comment 1 2012-12-20 11:48:40 PST
Created attachment 180376 [details] Repro layout test
Joshua Bell
Comment 2 2012-12-20 11:50:49 PST
Derived a specific layout test for this case from the steps in http://wkbug.com/102713 Fix should be similar to http://wkrev.com/138268
Joshua Bell
Comment 3 2012-12-20 16:48:46 PST
Joshua Bell
Comment 4 2012-12-20 16:49:05 PST
Just a snapshot - I haven't tried this in content_shell or looked at other browsers yet.
Joshua Bell
Comment 5 2012-12-21 08:52:06 PST
I think we can merge openConnection and openConnectionWithVersion - I may attempt to do that first and then rebase this patch.
Joshua Bell
Comment 6 2012-12-21 15:00:35 PST
Yeah, will rebase this on top of wkbug.com/105658
Joshua Bell
Comment 7 2012-12-21 16:24:34 PST
Joshua Bell
Comment 8 2012-12-21 16:25:17 PST
Rebased on top of http://wkrev.com/138400 - not broadly tested yet, though.
Joshua Bell
Comment 9 2012-12-26 10:15:52 PST
Our behavior (both with and without this patch) differs from both FF and IE. I reached out to public-webapps but no responses yet (presumably due to holidays).
Joshua Bell
Comment 10 2013-01-02 13:55:50 PST
dgrogan@, alecflett@ - pending feedback from other implementers, can you take a look? If the consensus is to match what other browsers do then I think we'd still want something based off this patch, but either make delete two-phase (like open) w/ the first phase that silently-waits followed by a second phase that does versionchange/blocked events. So I may push ahead with this. (I'll re-ping public-webapps on Monday when most folks should have recovered from the holidays.)
David Grogan
Comment 11 2013-02-06 17:33:54 PST
Comment on attachment 180572 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=180572&action=review > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:447 > + if (!m_pendingDeleteCalls.isEmpty() && !isDeleteDatabaseBlocked()) { The first clause of this condition isn't necessary, is it? Feel free to leave it in if you think it improves readability, though. > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:450 > + deleteDatabaseFinal(pendingDeleteCall->callbacks()); It looks like each pending delete call after the first has no effect, correct? But this is the simplest and clearest way to process them all. > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:457 > + ASSERT(m_pendingRunVersionChangeTransactionCalls.size() == 1); I can't convince myself that this assert is right. If there's an open connection with version 1 and script calls open("db", 2); open("db", 3), won't there be two entries? > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:582 > + if (connectionCount() > 1) You can remove this line. > Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:667 > + if (connectionCount() > 2) Your comment seems to indicate that this should be >= 2. > LayoutTests/storage/indexeddb/intversion-long-queue-expected.txt:64 > +FAIL event.oldVersion should be 1 (of type number). Was undefined (of type undefined). I think you've fixed these since you wrote this patch?
Joshua Bell
Comment 12 2013-02-08 15:00:35 PST
Comment on attachment 180572 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=180572&action=review Thanks for taking a look! >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:447 >> + if (!m_pendingDeleteCalls.isEmpty() && !isDeleteDatabaseBlocked()) { > > The first clause of this condition isn't necessary, is it? Feel free to leave it in if you think it improves readability, though. Correct; I'll remove it. >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:450 >> + deleteDatabaseFinal(pendingDeleteCall->callbacks()); > > It looks like each pending delete call after the first has no effect, correct? But this is the simplest and clearest way to process them all. They all get callbacks->onSuccess() called in deleteDatabaseFinal(). So... yeah, this seems clearest to me. >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:457 >> + ASSERT(m_pendingRunVersionChangeTransactionCalls.size() == 1); > > I can't convince myself that this assert is right. If there's an open connection with version 1 and script calls open("db", 2); open("db", 3), won't there be two entries? In that case there should be multiple entries in m_pendingOpenCalls but at most one of those should have gotten into the upgradeneeded phase. Does that make sense? (I confess it's been a while since I looked at this patch myself.) >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:582 >> + if (connectionCount() > 1) > > You can remove this line. Ah yes, thanks. >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:667 >> + if (connectionCount() > 2) > > Your comment seems to indicate that this should be >= 2. Ooops. I'll try and come up with a test that gets stuck on this invalid test before correcting it. >> LayoutTests/storage/indexeddb/intversion-long-queue-expected.txt:64 >> +FAIL event.oldVersion should be 1 (of type number). Was undefined (of type undefined). > > I think you've fixed these since you wrote this patch? Yep. Will need rebasing.
Joshua Bell
Comment 13 2013-02-12 14:33:45 PST
Joshua Bell
Comment 14 2013-02-12 14:35:56 PST
Updated patch with feedback from comments and rebased. (In reply to comment #12) > > >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:457 > >> + ASSERT(m_pendingRunVersionChangeTransactionCalls.size() == 1); > > > > I can't convince myself that this assert is right. If there's an open connection with version 1 and script calls open("db", 2); open("db", 3), won't there be two entries? > > In that case there should be multiple entries in m_pendingOpenCalls but at most one of those should have gotten into the upgradeneeded phase. > > Does that make sense? (I confess it's been a while since I looked at this patch myself.) dgrogan@ - No change to the patch here - can you take another look, though? > >> Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp:667 > >> + if (connectionCount() > 2) > > > > Your comment seems to indicate that this should be >= 2. > > Ooops. I'll try and come up with a test that gets stuck on this invalid test before correcting it. Fixed, but the previous code just would have resulted in extra no-op calls to processPendingCalls() if connectionCount() == 2 so the behavior can't be distinguished.
Joshua Bell
Comment 15 2013-02-25 11:28:16 PST
(In reply to comment #9) > Our behavior (both with and without this patch) differs from both FF and IE. I reached out to public-webapps but no responses yet (presumably due to holidays). FYI, sounds like Firefox considers their behavior buggy. No word from IE.
Joshua Bell
Comment 16 2013-02-25 11:28:49 PST
(In reply to comment #14) > Updated patch with feedback from comments and rebased. > > dgrogan@ - can you take another look, though? ping?
Joshua Bell
Comment 17 2013-03-11 14:06:36 PDT
Joshua Bell
Comment 18 2013-03-11 14:07:45 PDT
Rebased. dgrogan@ - can you take a look? See response to questions above.
Build Bot
Comment 19 2013-03-11 19:16:39 PDT
Comment on attachment 192552 [details] Patch Attachment 192552 [details] did not pass mac-ews (mac): Output: http://webkit-commit-queue.appspot.com/results/17161445 New failing tests: editing/selection/selection-modify-crash.html
Joshua Bell
Comment 20 2013-03-12 09:10:09 PDT
(In reply to comment #19) > New failing tests: > editing/selection/selection-modify-crash.html I'm guessing that's unrelated. :)
Joshua Bell
Comment 21 2013-04-01 13:14:05 PDT
Joshua Bell
Comment 22 2013-04-01 13:14:19 PDT
(In reply to comment #21) > Created an attachment (id=196011) [details] > Patch Just a rebase.
Levi Weintraub
Comment 23 2013-04-08 10:50:19 PDT
Should this be moved to blink? If so, please clear the flags on the patch and mark this bug as invalid.
Joshua Bell
Comment 24 2013-04-11 09:12:33 PDT
I've copied this to blink. The issue/patch is still valid for WebKit. I'm pinging possible new owners.
Radar WebKit Bug Importer
Comment 25 2022-07-11 14:55:23 PDT
Sihui Liu
Comment 26 2022-08-01 18:56:06 PDT
We've refactored the code a lot since the bug was fired, and we won't fire two blocked events on one IDBOpenDBRequest nowadays, see ServerOpenDBRequest::maybeNotifyRequestBlocked. Also the test LayoutTests/storage/indexeddb/double-blocked-on-open.html added in the patch does not conform to the spec nowadays: new request won't be processed until the previous requests are completed, see https://www.w3.org/TR/IndexedDB/#connection-queues and https://www.w3.org/TR/IndexedDB/#opening. So I will close this bug.
Note You need to log in before you can comment on or make changes to this bug.