-
Notifications
You must be signed in to change notification settings - Fork 2
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
Data consistency: queue tasks in transaction #277
Comments
We also need some way of handling plugins. E.g. in the |
In particular, here are some things that ought to work:
I had been thinking about keeping track of when one entry depends on another (e.g. Göteborg depends on Göteborgs kommun), but that doesn't work in case 2 since there's no existing entry to depend on. I guess in this case we could run an Elasticsearch query to find out which places to update - give me all places that refer to Göteborgs kommun (or rather municipality = 1480)? Not sure how this would work in general. |
Using Elasticsearch to find all references is probably enough and that has to be in the task table as well, created in the same transaction as the original edit. |
Since the linking is done in a plugin, I guess the plugin should be responsible for this behavior. Not sure how to trigger it though, since the resource being referenced doesn't know anything about the plugin. |
We use MariaDB for persistence and ES for search. When we save something in MariaDB, we are not sure that it will be added to ES, since ES might be down or not answer for some reason. Currently we have no way to even detect if something like that happens (though it should be possible to see in logs, in theory).
To solve this, add a new table for queuing tasks to be done in the background. The tasks can be adding, deleting or updating entries in ES. The tasks are added in the same transaction as adding, deleting or updating in MariaDB. Some process will look in the tasks-table and do the tasks in the background. If the task was completed, the process removes the row in the table.
What can still happen is that the background worker fails to remove the row in the tasks-table even though the task succeeded. Because of this, it is important that the tasks are idempotent, i.e. can be run again without breaking the data consistency. Also, the order of the tasks matter, for example if the same entry is edited again before the worker has processed the first edit.
The text was updated successfully, but these errors were encountered: