WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 91456
IndexedDB: Key generator state not maintained across connections
https://bugs.webkit.org/show_bug.cgi?id=91456
Summary
IndexedDB: Key generator state not maintained across connections
Joshua Bell
Reported
2012-07-16 17:45:23 PDT
Created
attachment 152658
[details]
Repro case - should show different keys The IDB spec
http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-generator-concept
says: "The current number for a key generator never decreases, other than as a result of database operations being reverted. Deleting a record from an object store never affects the object store's key generator. Even clearing all records from an object store, for example using the clear() function, does not affect the current number of the object store's key generator." The WebKit implementation violates this in this case: db.open(...); store.put(value1); store.clear(); db.close(); db.open(); store.put(value2); The same key will be used for value2 as was used for value1. This is because the key generator state is not actually saved, but derived from the maximum key in the database at the time it is first needed.
Attachments
Repro case - should show different keys
(1.54 KB, text/html)
2012-07-16 17:45 PDT
,
Joshua Bell
no flags
Details
Patch
(27.78 KB, patch)
2012-07-17 12:37 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(27.76 KB, patch)
2012-07-17 13:06 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(29.84 KB, patch)
2012-07-17 13:39 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(30.67 KB, patch)
2012-07-17 15:41 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch for landing
(30.76 KB, patch)
2012-07-17 16:29 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Joshua Bell
Comment 1
2012-07-17 09:20:58 PDT
I'll take this. Should be pretty easy...
Joshua Bell
Comment 2
2012-07-17 12:37:39 PDT
Created
attachment 152806
[details]
Patch
Joshua Bell
Comment 3
2012-07-17 12:38:23 PDT
dgrogan@, alecflett@ - please take a look. Opinions on deferring updated caching logic to a subsequent patch?
David Grogan
Comment 4
2012-07-17 12:45:19 PDT
(In reply to
comment #3
)
> dgrogan@, alecflett@ - please take a look. > > Opinions on deferring updated caching logic to a subsequent patch?
Defer.
WebKit Review Bot
Comment 5
2012-07-17 13:02:04 PDT
Comment on
attachment 152806
[details]
Patch
Attachment 152806
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13279234
Joshua Bell
Comment 6
2012-07-17 13:04:04 PDT
(In reply to
comment #5
)
> (From update of
attachment 152806
[details]
) >
Attachment 152806
[details]
did not pass chromium-ews (chromium-xvfb): > Output:
http://queues.webkit.org/results/13279234
Whoops, guess I didn't test a during-upload refactor. New patching coming momentarily...
Joshua Bell
Comment 7
2012-07-17 13:06:53 PDT
Created
attachment 152810
[details]
Patch
WebKit Review Bot
Comment 8
2012-07-17 13:12:43 PDT
Comment on
attachment 152810
[details]
Patch
Attachment 152810
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13270241
Joshua Bell
Comment 9
2012-07-17 13:39:18 PDT
Created
attachment 152815
[details]
Patch
Joshua Bell
Comment 10
2012-07-17 14:35:17 PDT
There we go - final looks before I send this off for review?
David Grogan
Comment 11
2012-07-17 15:13:42 PDT
Comment on
attachment 152815
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=152815&action=review
LGTM I didn't look too closely. It'd be good if Alec could also look.
> Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:420 > + keyGeneratorState = decodeInt(it->value().begin(), it->value().end());
Do you want to add some assert here? Or a fixme saying that this is unused for now but could be used?
> Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:506 > + ok = putInt(m_currentTransaction.get(), keyGeneratorStateKey, 1);
Could you add a constant or comment about the bare 1?
Alec Flett
Comment 12
2012-07-17 15:17:19 PDT
Comment on
attachment 152815
[details]
Patch sorry I have this habit of not commenting when it looks good...LGTM! I was briefly happy to see that kMaxGeneratorValue was moving out to IDBKey, but I see that was just a typo :)
Joshua Bell
Comment 13
2012-07-17 15:41:13 PDT
Created
attachment 152854
[details]
Patch
Joshua Bell
Comment 14
2012-07-17 15:42:44 PDT
(In reply to
comment #11
)
> Do you want to add some assert here? Or a fixme saying that this is unused for now but could be used?
Done (both)
> > Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:506 > > + ok = putInt(m_currentTransaction.get(), keyGeneratorStateKey, 1); > > Could you add a constant or comment about the bare 1?
Add constant, used here and in above assert. I also did s/State/CurrentNumber/g over the patch to better match the spec terminology. tony@ - r?
Tony Chang
Comment 15
2012-07-17 16:03:13 PDT
Comment on
attachment 152854
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=152854&action=review
> Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:50 > +const int64_t kKeyGeneratorInitialNumber = 1; // From the IndexedDB specification.
Nit: Normally we don't prefix constants or enum values with k. KeyGeneratorInitialNumber is fine. Hmm, I see you use k for constants in other places. Maybe a follow up patch to remove all the k prefixes in IDB code?
> Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:680 > + const char *p = it->key().begin(); > + const char *limit = it->key().end();
Nit: * next to char. E.g., const char* p =
Joshua Bell
Comment 16
2012-07-17 16:29:00 PDT
Created
attachment 152869
[details]
Patch for landing
Joshua Bell
Comment 17
2012-07-17 16:30:17 PDT
(In reply to
comment #15
)
> Nit: Normally we don't prefix constants or enum values with k. KeyGeneratorInitialNumber is fine. Hmm, I see you use k for constants in other places. Maybe a follow up patch to remove all the k prefixes in IDB code?
Fixed, and will do.
> > Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp:680 > > + const char *p = it->key().begin(); > > + const char *limit = it->key().end(); > > Nit: * next to char. E.g., const char* p =
Yeah, that was an indentation of existing code. Fixed, and will do a global fixup in the followup patch.
WebKit Review Bot
Comment 18
2012-07-17 18:07:40 PDT
Comment on
attachment 152869
[details]
Patch for landing Clearing flags on attachment: 152869 Committed
r122909
: <
http://trac.webkit.org/changeset/122909
>
WebKit Review Bot
Comment 19
2012-07-17 18:07:46 PDT
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.
Top of Page
Format For Printing
XML
Clone This Bug