Closed
Bug 1207468
Opened 9 years ago
Closed 9 years ago
Prefix asyncStorage entries with userid in DataAdapters
Categories
(Firefox OS Graveyard :: Sync, defect, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
FxOS-S10 (30Oct)
People
(Reporter: mbdejong, Assigned: mbdejong)
References
Details
Attachments
(1 file)
This is a follow-up to bug 1191773.
The way it uses an asyncStorage data base to map FxSync Id <-> DataStore Id takes up disk space and processing time, so maybe we can do something smarter.
Suggestion 1: Implement and use https://github.com/Kinto/kinto.js/issues/173
Suggestion 2: Store records in the DataStore by their FxSync Id (what would be the implications of that for other apps? would a data migration be needed)?
Suggestion 3: ... ?
Assignee | ||
Updated•9 years ago
|
Assignee | ||
Comment 1•9 years ago
|
||
Re suggestion 2: We're currently using the URL as the id in DataStore, so that's obviously not going to fly if we change that. https://github.com/weilonge/gaia/blob/seanlee/DataSync/master/Bug1191773/apps/sync/js/adapters/history.js#L114
Assignee | ||
Comment 2•9 years ago
|
||
Possible suggestion 3: A 'dry run' option in Kinto.js `Collection#sync`. That would allow us to inspect the SyncResults object from Kinto.js to know what to change in the DataStore (while still having access to the unchanged records). We could then apply the incoming changes one-by-one as we process them, meaning that if something goes wrong before we processed the whole SyncResults (e.g. app is brutally killed), we will still get those unprocessed changes on next sync. The ones that we did apply will show up as 'skipped' in the next sync. It's not so efficient in updating Kinto.js's lastModified timestamp, and will lead to extra bandwidth usage (which is not nice on mobile), but maybe we can iterate over this thought.
Assignee | ||
Comment 3•9 years ago
|
||
Suggestion 4 (variation on suggestion 3): Pass a second RemoteTransformer to Kinto.js, from which the adapter can inspect each incoming change before it gets committed.
Comment 4•9 years ago
|
||
Hey Michiel,
Thanks for your suggestions. :)
For suggestion 4, I checked RemoteTransformer example http://kintojs.readthedocs.org/en/latest/api/#listing-records .
Is it possible to get the original URL (aka. DataStoreID) for deleted: true record?
class MyRemoteTransformer extends Kinto.transformers.RemoteTransformer {
encode(record) { <<< Will it contain URL information here?
return update(record, {title: record.title + "!"});
}
decode(record) {
return update(record, {title: record.title.slice(0, -1)});
}
}
Comment 5•9 years ago
|
||
Correct my above comment, I think the URL information would be at decode function rather than encode, and I suppose that URL will be in payload object:
Delete Records from History Collection (HC): {
"id": "_Avscjx5srFy",
"sortindex": 100,
"last_modified": 1441985077970,
"payload": {
"url": "http://mozilla.org",
"id": "_Avscjx5srFy",
"deleted": true
},
"_status": "synced"
}
Assignee | ||
Comment 6•9 years ago
|
||
New insight: https://github.com/Kinto/kinto.js/issues/173#issuecomment-145007083
Seems nicer than spying through a RemoteTransformer.
Assignee | ||
Updated•9 years ago
|
Target Milestone: FxOS-S9 (16Oct) → FxOS-S10 (30Oct)
Assignee | ||
Updated•9 years ago
|
Priority: -- → P3
Assignee | ||
Comment 7•9 years ago
|
||
As discussed today, we will store this mapping in localStorage, and prefixed with the email address of the logged in user. On the TV (but not on the phone), this data will be deleted when the user logs out.
Assignee | ||
Updated•9 years ago
|
Summary: Make FxSync Id <-> DataStore Id mapping more efficient in History Adapter → Store FxSync Id <-> DataStore Id mapping prefixed with user email in History Adapter
Comment 9•9 years ago
|
||
Assignee | ||
Updated•9 years ago
|
Attachment #8676186 -
Flags: review?(ferjmoreno)
Assignee | ||
Updated•9 years ago
|
Summary: Store FxSync Id <-> DataStore Id mapping prefixed with user email in History Adapter → Prefix asyncStorage entries with userid in DataAdapters
Updated•9 years ago
|
Priority: P3 → P1
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8676186 [details] [review]
[gaia] michielbdejong:1207468-fxsyncid-datastoreid-mapping > mozilla-b2g:master
Treeherder shows an ESL error, but I can't see why?
Assignee | ||
Comment 11•9 years ago
|
||
(In reply to Michiel de Jong [:michielbdejong] from comment #10)
> Comment on attachment 8676186 [details] [review]
> [gaia] michielbdejong:1207468-fxsyncid-datastoreid-mapping >
> mozilla-b2g:master
>
> Treeherder shows an ESL error, but I can't see why?
Ah, green after a rebase.
Please review.
Flags: needinfo?(ferjmoreno)
Updated•9 years ago
|
Flags: needinfo?(ferjmoreno)
Attachment #8676186 -
Flags: review?(ferjmoreno) → review+
Assignee | ||
Comment 12•9 years ago
|
||
IIRC, when the Sync server is flushed, kB and xClientState will change, right? We should find out if the fxSyncIds also change in this case. If they do, then using xClientState here is correct, but if not then it's more correct to use the email address of the current user.
Assignee | ||
Comment 13•9 years ago
|
||
(In reply to Michiel de Jong [:michielbdejong] from comment #12)
> IIRC, when the Sync server is flushed, kB and xClientState will change,
> right? We should find out if the fxSyncIds also change in this case. If they
> do, then using xClientState here is correct, but if not then it's more
> correct to use the email address of the current user.
Created P2 follow-up bug 1218286 about this.
Assignee | ||
Comment 14•9 years ago
|
||
Incorporated your first review comment https://github.com/mozilla-b2g/gaia/pull/32596#discussion_r42936908 and created a follow-up bug for your second review comment https://github.com/mozilla-b2g/gaia/pull/32596#discussion_r42936922. Rebased, tests are green.
Flags: needinfo?(ferjmoreno)
Comment 15•9 years ago
|
||
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: needinfo?(ferjmoreno)
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•