hail
hail copied to clipboard
[batch] Add real time billing!
Stacked on #11997
This PR enables real-time billing. It should be relatively straightforward. It uses the MySQL v8 instant add of a column. Therefore, we need to switch the Azure infrastructure to use V8.0 before this PR merges. I'm not sure how long this update will lock the attempts table, but hopefully it's not too long. I can test it out on my test database next week. This is an online migration.
The key thing to double check is I got the trigger updates to use the new rollup_time
correctly and am not missing any updates to the attempts where the rollup time needs to be updated as well.
cc: @danking
Ready for a first look!
I think that my unease here is that there's a lot of engineering around the assumption that attempts might not get inserted right away through the intended path (we add attempts in so many different places!)
Can you elaborate on this? We indirectly add attempts via SJ, MJS, and MJC via the add_attempt
stored procedure and now directly in the billing update which should almost never be an insert unless Batch is overwhelmed.
and now directly in the billing update which should almost never be an insert unless Batch is overwhelmed.
This is my point. I don't see why we should add another place where we add attempts. I think the billing update should only update attempts that already exist, and the attempts_after_insert
trigger doesn't have to account for rollups, only the attempts_after_update
trigger.
I don't know how to write this operation other than to do an insert on duplicate key update or to do a for loop and update each attempt individually.
@danking Do you know of a better way to update multiple values in a single query?