Make Google API call in the background #5
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we execute up to 3 API calls in the
/confirm
endpoint:However, we've been running into
SSLEOF
errors when calling the Google API.Internal reference: https://watonomous.sentry.io/issues/5728320814/?project=4507799285989376&query=is:unresolved+issue.priority:%5Bhigh,+medium%5D+!namespace:mimir+!namespace:wato-finance-frontend+!namespace:wato-finance-backend&statsPeriod=24h&stream_index=0
According to this, it's something to do with not having consistent CPU resources. Without digging into the details, we implement something that is general enough to handle this.
This PR offloads the Google API call to the background. Now, the
/confirm
endpoint simply:And we run a background job called
commit
to do the rest:The background job is idempotent, so we can retry it when it fails. We keep track of the last successful commit and healthcheck based on it.
During manual testing, if we trigger an exception in the background job loop, it will not interrupt the loop.
This PR changes the RowKey format and is not backwards compatible.
Tested and working in prod. It turns out the local instance of azure tables allows "eq null" (not sure if it works because "ne null" certainly doesn't work) and the cloud one doesn't. It has the error