Conversation
| We will use ``sort=last_modified`` and ``_since=<timestamp>``: | ||
|
|
||
| #. First sync: ``timestamp := 0`` | ||
| #. Next sync: ``timestamp := MAX(local_records['last_modified'])`` |
There was a problem hiding this comment.
timestamp := MAX(local_records['last_modified'])-1 because it may be that two or more changes happened during the same timestamp, and you did not get all of them during the first sync.
This is especially relevant if you combine this with _limit. For instance, in FxSync you sometimes see 1000 records with the exact same timestamp, so you shouldn't discard 950 of them after fetching only the first 50.
There was a problem hiding this comment.
because it may be that two or more changes happened during the same timestamp
This is not possible on server side. Even if two records happens at the same timestamp, they will have different timestamps.
See http://kinto.readthedocs.org/en/latest/api/1.x/cliquet/timestamps.html
There was a problem hiding this comment.
in FxSync you sometimes see 1000 records with the exact same timestamp, so you shouldn't discard 950 of them after fetching only the first 50.
This is a real problem for syncto because Kinto guarantees that it won't happend. If Sync doesn't it means that we have a problem in syncto.
|
Very clear and insightful, answers a bunch of questions I had; r+. |
Yeah, I changed it. In the third approach, they both go backwards. One fetches the old records with |
docs/api/1.x/synchronisation.rst
Outdated
|
|
||
| #. Obtain a few pages of recent records using the *newest first* strategy from above | ||
| #. In background, fetch old records using ``_sort=-lastmodified`` and ``_before=MIN(local_records[last_modified])`` | ||
| #. Recent changes can be obtained using ``_sort=-lastmodified`` and ``_since=MAX(local_records[last_modified])`` |
There was a problem hiding this comment.
I still think you'll skip records with this strategy unless you can be sure that each record has a unique lastmodified timestamp. As soon as you have 1 local record with a given timestamp, all other remote records with that same timestamp will be ignored, right?
Improve synchronisation docs
Fix profiling setup (docs and code)
@Natim @michielbdejong @n1k0 feeback ?