Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental Updates: honor events before changed_at #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oxzi
Copy link
Member

@oxzi oxzi commented Jul 12, 2024

As changes might not be committed in the database in a continuous linear fashions, elements out of order might get ignored. This change adds a window to the past for incrementalFetch, honoring older elements. The incrementalApplyPending function now compares the changed_at value for known elements, skipping those without a change.

As changes might not be committed in the database in a continuous linear
fashions, elements out of order might get ignored. This change adds a
window to the past for incrementalFetch, honoring older elements. The
incrementalApplyPending function now compares the changed_at value for
known elements, skipping those without a change.
@oxzi oxzi added the bug Something isn't working label Jul 12, 2024
@oxzi oxzi requested a review from julianbrost July 12, 2024 13:33
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Jul 12, 2024
@oxzi
Copy link
Member Author

oxzi commented Jul 15, 2024

Something to note about this PR change is that it will retry the changes within each table for the last ten minutes. Since it will silently abort if the changed_at value has not changed or the item is deleted again, it does no real work, but it is not really clean, but more a hacky solution.

Another idea I toyed with was to use not only the last changed_at value, but also the current timestamp iff a changed_at value has already been fetched. For example, use min(changed_at - 10m, current_timestamp - 30m). In my naive thinking, this sliding time window would slowly catch up the fixed changed_at timestamp, while still being large enough to catch the weirdest of time travelers1.

To be really sure, another layer could be added to query each known element if it has another changed_at or deleted value and to query for everything with an unknown primary key. This, however, should only be done once in a while.

Footnotes

  1. In case of a long lasting split brain situations of a database cluster, other issues might arise as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant