Skip to content

Losing updates when using afterTimestamp and afterId #95

@nathansalter

Description

@nathansalter

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions