-
Notifications
You must be signed in to change notification settings - Fork 3
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
Clean up or reduce failures on move creation #1795
Comments
Another option might be to combine the steps on the API side, so it can use database transactions and have better control over the eventual consistency of this step. This does lead to the API needing a bespoke endpoint though to perform all these steps - which might not be desirable. |
One another solution could be to introduce some sort of "transaction" on the API side, so the frontend client would do something like:
The "transaction id" would then we used in each of the calls to link them together. However, this feels like we would be duplicating behaviour that the database already supports and it's not something I'd probably recommend we do. |
Personally, I'd be in favour of pushing this sort of behaviour to the API and rely on database transactions to guarantee consistency. From an API architecture I can see that this might not be the desired outcome, but without introducing our own concept of transactions, any other solution doesn't fully solve the problem in my opinion. |
For what it's worth, I'm in favour of this being handled by the API as Tom suggests. Historically, the "front-end" has been set up to handle fairly complicated business logic, which is not desirable, and this is an example of where it can cause issues. Worth noting that I think one of the transactions - court_hearings - also attempts to add records to NOMIS (if I'm thinking about the right area). This may be worth handling separately. Right now (via the front-end), we don't fail the whole transaction if that piece fails, and instead report an error (I think these go to Sentry for investigation), and tell the user so they can optionally add the court dates to NOMIS manually. We should consider keeping this behaviour, but perhaps via the API |
Problem
During move creation the final step makes a series of calls to the API:
POST /moves
- to create the movePOST /court_hearings
x n - for each court hearing associated with this movePATCH /people/:id/profiles
- to update the profile withrequires_youth_risk_assessment
,assessment_answers
,documents
attributes and anything else that has updated during the creation stepsIn some cases one of these calls can fail, for example a timeout or Bad Gateway, and in worst case the final
PATCH
can fail. This leads to the scenario that the move has been created and requested but the profile associated with that move doesn't contain all the correct, up-to-date information.Sentry example for a failed
PATCH
transaction.Possible solutions
Reduce calls on final step
Some of the calls made on the final step could be moved to other parts of the process. For example, the
PATCH
to the profile could be moved to the assessment controller and make updates on each step.Pros
Cons
Cancel move on failures
Pros
Cons
The text was updated successfully, but these errors were encountered: