Bug 59822 - IndexedDB does not update r/w index cursors that are mutated during iteration
Summary: IndexedDB does not update r/w index cursors that are mutated during iteration
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Joshua Bell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-29 13:25 PDT by Mark Pilgrim (Google)
Modified: 2012-01-27 16:05 PST (History)
7 users (show)

See Also:


Attachments
Test case (6.78 KB, patch)
2011-04-29 13:26 PDT, Mark Pilgrim (Google)
no flags Details | Formatted Diff | Diff
updated test case (5.56 KB, text/html)
2011-12-07 13:38 PST, Joshua Bell
no flags Details
Patch (11.41 KB, patch)
2012-01-27 15:37 PST, Joshua Bell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Pilgrim (Google) 2011-04-29 13:25:32 PDT
Original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_cursor_mutation.html?raw=1
Ported test: see attachment

The scenario here is that you have an object store with data in it, and an index on one of the fields. (In the attached test, the index is an alphabetical index of first names.) You open a read/write transaction and use it to open a cursor on the index. While iterating through the cursor (in alphabetical order), you mutate the object store to add another row whose values would not yet have shown up in iteration.

Expected result: the index cursor should automatically update to include the new row when it eventually comes up in the alphabetical order (of the index). The mutation occurs before the added name would have appeared in the cursor iteration, thus the iteration should eventually find it.

Actual result: WebKit's behavior is to skip over the row that was added during iteration. Iteration of the index cursor continues in the expected (alphabetical) order through the original data in the object store, but the added row is never found.
Comment 1 Mark Pilgrim (Google) 2011-04-29 13:26:41 PDT
Created attachment 91723 [details]
Test case
Comment 2 Mark Pilgrim (Google) 2011-04-29 13:27:45 PDT
Not a patch, just a test case. Removed spurious review flag.
Comment 3 David Grogan 2011-04-29 14:11:40 PDT
Just curious, do we correctly handle this case if the cursor is iterating over an objectstore rather than an index?
Comment 4 Mark Pilgrim (Google) 2011-05-02 06:40:11 PDT
Yes, see bug 59933.
Comment 5 Hans Wennborg 2011-05-03 03:00:09 PDT
(In reply to comment #4)
> Yes, see bug 59933.

Hmm, that's interesting. Thanks for finding this.
Comment 6 Joshua Bell 2011-12-07 13:38:13 PST
Created attachment 118266 [details]
updated test case

No repro for me. This may have been fixed with the move to LevelDB.

The attached test case was a bit crufty; I dusted it off (attached) and it works fine.
Comment 7 Joshua Bell 2011-12-07 13:40:36 PST
On further thought, we should probably pull in this test, but perhaps keep it closer to the original moz test than my edit.
Comment 8 Joshua Bell 2012-01-27 15:37:00 PST
Created attachment 124384 [details]
Patch
Comment 9 Joshua Bell 2012-01-27 15:37:48 PST
Comment on attachment 124384 [details]
Patch

Dusted off the original patch a bit. Still passes as expected.
Comment 10 David Grogan 2012-01-27 15:41:05 PST
Comment on attachment 124384 [details]
Patch

LGTM
Comment 11 WebKit Review Bot 2012-01-27 16:05:10 PST
Comment on attachment 124384 [details]
Patch

Clearing flags on attachment: 124384

Committed r106165: <http://trac.webkit.org/changeset/106165>
Comment 12 WebKit Review Bot 2012-01-27 16:05:15 PST
All reviewed patches have been landed.  Closing bug.