-
Notifications
You must be signed in to change notification settings - Fork 152
persist current auction in background task #3861
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
base: main
Are you sure you want to change the base?
Conversation
| id: domain::auction::Id, | ||
| auction: &domain::RawAuctionData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the variables could have better names, it's kind of hard to tell which is which by just looking at it. Is the ID the new one, or is it contained in AuctionData?
| let mut ex = self.pool.acquire().await?; | ||
| let id = database::auction::replace_auction(&mut ex, &data).await?; | ||
| Ok(id) | ||
| database::auction::insert_auction_with_id(&mut ex, id, &data).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To supplement my point, I'd have to dive up to here to understand that idis the new auction ID
| Ok(key) => tracing::info!(?key, "uploaded auction to s3"), | ||
| Err(err) => tracing::warn!(?err, "failed to upload auction to s3"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the auction id to the logs too? I'm not sure the error has it
squadgazzz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change looks a bit risky and awkward to me. How about introducing a simple table with an auction_id counter as the safest approach?
|
I think there is a potential issue with ordering - it could happen, however unlikely, that you spawn a taks T1, then T2, but T2 finishes before T1 and writes T1 writes over a newer auction. 🤔 |
|
This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed. |
Description
Currently the autopilot assembles the contents of the auction and then persists it in the DB by replacing the current auction with the new one which also returns the ID for the new auction.
This is unfortunately pretty slow (~440ms on prod mainnet) and therefor significantly increases the delay between seeing a new block and sending the fully assembled auction to solvers.
Changes
What we can do instead is to introduce a new DB query that just increments and returns the auction id counter for the next auction. Afterwards we spawn a background task that writes the fully assembled auction to the DB and uploads it to S3.
The trade-off is that it's now possible that we fully run an auction that we don't have persisted anywhere. But in practice this does not happen (no instance in the last 30d) and this information is for debugging purposes anyway.
How to test
e2e tests