hail icon indicating copy to clipboard operation
hail copied to clipboard

[batch] Add real time billing!

Open jigold opened this issue 1 year ago • 1 comments

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.

jigold avatar Jul 03 '22 23:07 jigold

cc: @danking

jigold avatar Jul 08 '22 15:07 jigold

Ready for a first look!

jigold avatar Aug 22 '22 17:08 jigold

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.

jigold avatar Aug 22 '22 19:08 jigold

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.

daniel-goldstein avatar Aug 22 '22 19:08 daniel-goldstein

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?

jigold avatar Aug 22 '22 19:08 jigold