Hello,
I started to look through the documentation and I noticed a slight problem with the afterTimestamp/afterId method of iterating through pages. This is fine for pages in the past, but pages happening after the current timestamp can possibly lose items from the subsequent pages. Consider the following updates in this sequence:
| Operation |
ID |
Timestamp |
| Create |
1 |
1585747490 |
| Create |
2 |
1585747491 |
| Update |
5 |
1585747492 |
| Update |
4 |
1585747492 |
| Create |
7 |
1585747493 |
Now if a client views a page between the Update of ID 5 and the Update of ID 4, they will get this page:
| Operation |
ID |
Timestamp |
| Create |
1 |
1585747490 |
| Create |
2 |
1585747491 |
| Update |
5 |
1585747492 |
However, using the afterId of 5 and afterTimestamp of 1585747492 will produce this next page:
| Operation |
ID |
Timestamp |
| Create |
7 |
1585747493 |
Because the ID for 4 is sorted after the afterTimestamp so cannot appear in the page starting with the afterId of 5 so the update is lost.
I'm not sure how this problem could be fixed in the specification, except by removing the requirement that items MUST be sorted by id and instead allowing them to be sorted by the order in which the updates actually occur. We've mitigated this issue slightly by using microseconds rather than seconds in the timestamp but the problem could still occur on high-traffic websites.
Does anyone have any better suggestions?
Hello,
I started to look through the documentation and I noticed a slight problem with the afterTimestamp/afterId method of iterating through pages. This is fine for pages in the past, but pages happening after the current timestamp can possibly lose items from the subsequent pages. Consider the following updates in this sequence:
Now if a client views a page between the Update of ID 5 and the Update of ID 4, they will get this page:
However, using the
afterIdof5andafterTimestampof1585747492will produce this next page:Because the ID for
4is sorted after theafterTimestampso cannot appear in the page starting with theafterIdof5so the update is lost.I'm not sure how this problem could be fixed in the specification, except by removing the requirement that items MUST be sorted by id and instead allowing them to be sorted by the order in which the updates actually occur. We've mitigated this issue slightly by using microseconds rather than seconds in the timestamp but the problem could still occur on high-traffic websites.
Does anyone have any better suggestions?