Implement idempotency & message queue for critical operations #7656
Labels
🔬 Needs tech design
This ticket is waiting for technical design
💾 Persistence
Storage, databases & data formats related tasks
Tech
Design principles
We need to handle errors in the system more gracefully. If there is any error whilst processing an application so that the data is never lost. The following approach aims to
Note
A proof of concept of this has been implemented in this PR. The changes only apply for when a completely new record is created so the approach needs to be extended to other operations.
Requirements
Client should never purge draft unless it can verify the record was fully written. To do this, it needs to verify the record was received either by
Status should never be OK and the client should never remove the local record before metadata is persisted in MongoDB, attachments are stored in Minio and search indexing happens in Elasticsearch. If any of these fails, the record stays in the queue indefinitely and alerts are sent to system admin.
If one of these steps fails, the backend needs to work so the client can safely retry without duplicate entries. In other words, the backend operations need to be idempotent. The outcome in the database should be the same even if you first unsuccessfully submit a record 10 times, then submit it successfully once and then try submitting it 5 more times. The output should be one record written in the database.
The endpoints that this apply to are at this phase the ones writing mission critical data with a lot of user input that might not be available anymore after a potential failure. Specifically these queries:
Important
Tech design: What other operations should we consider?
Note
Proof of concept implements a message queue and retrying for create[Event]Registration operations.
Tech tasks
The text was updated successfully, but these errors were encountered: