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 config update limitations #226

Open
2 of 4 tasks
sukhwinder33445 opened this issue Jul 11, 2024 · 3 comments
Open
2 of 4 tasks

Incremental config update limitations #226

sukhwinder33445 opened this issue Jul 11, 2024 · 3 comments
Labels
area/configuration Affects the configuration

Comments

@sukhwinder33445
Copy link
Contributor

sukhwinder33445 commented Jul 11, 2024

Event rule

  • Removing an event rule escalation causes the changed_at flag to be updated for all other escalations.
  • Adding/removing/updating a recipient causes the escalation and all its recipients to have a new changed_at.

The changed_at column

@nilmerg
Copy link
Member

nilmerg commented Jul 12, 2024

It should be precise to milliseconds in order to avoid a data race (daemon side), e.g. if two users update the data at the same time.

If two users update the same configuration at the same time, one should get a conflict and need to re-submit. This is no reason to increase precision on the timestamp values.

@nilmerg
Copy link
Member

nilmerg commented Jul 15, 2024

It should be precise to milliseconds in order to avoid a data race (daemon side), e.g. if two users update the data at the same time.

If two users update the same configuration at the same time, one should get a conflict and need to re-submit. This is no reason to increase precision on the timestamp values.

Though, in case it's not possible to differentiate between new and updated entries (which is the case), it is...

@nilmerg nilmerg added the area/configuration Affects the configuration label Jan 21, 2025
@Al2Klimov
Copy link
Member

Al2Klimov commented Mar 3, 2025

a data race (daemon side), e.g. if two users update the data at the same time

Indeed!

Now, if an insertion is slow enough and/or clocks are just a bit out of sync (e.g CockroachDB allows +-7ms), two config updates which differ only by 1-2 ms could be inserted out of order, so that one gets lost:

  1. A get inserted with changed_at=123
  2. Daemon consumes A
  3. B get inserted with changed_at=122
  4. Daemon does nothing, as it thinks it has already consumed everything 🤷‍♂

Actually time() knows only seconds, so race conditions even apply to two config updates during the same second. #306

Suggestion

  1. Do all DML ops affecting changed_at columns inside serializable transactions
  2. In case of Serialization Failure (error 1213/40001), repeat the transaction (loop)
  3. Insert not just ms_time_from_php(), but GREATEST(ms_time_from_php(), MAX(changed_at)+1)

This way, rows updated later will always have a greater changed_at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration Affects the configuration
Projects
None yet
Development

No branches or pull requests

3 participants