Only generate new auction_id for non-empty auctions#4314
Only generate new auction_id for non-empty auctions#4314MartinquaXD wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes the autopilot run loop by skipping auction ID generation and database persistence when an auction contains no orders. Additionally, it removes the wait_until_autopilot_ready synchronization step from the E2E test setup. Feedback indicates that removing this readiness check may introduce race conditions in CI environments, and it is recommended to implement a more reliable synchronization method that does not depend on non-empty auctions.
| self.wait_until_autopilot_ready().await; | ||
|
|
||
| join_handle | ||
| tokio::task::spawn(autopilot::run(config, control)) |
There was a problem hiding this comment.
Removing the readiness check wait_until_autopilot_ready() introduces a potential race condition in E2E tests. While the autopilot might be fast to start, CI environments are often resource-constrained and slower, which can lead to flaky tests if they attempt to place orders or verify state before the autopilot's background tasks (like cache warming and event listeners) are fully initialized. Instead of removing the synchronization entirely, consider implementing a readiness check that doesn't rely on non-empty auctions, such as polling the autopilot's metrics endpoint or checking for the startup probe to be set.
References
- For integration tests, prioritize CI stability by ensuring robust synchronization and handling potential environment-related delays gracefully.
Description
Currently we first generate a new auction id before checking whether the auction contains any orders in the first place. This can lead to confusion where one would expect auction data for some auction to be present in the DB but there is actually none.
Changes
This PR addresses that by first checking whether the auction is empty and only generating a new auction_id when it's not.
This could have been addressed earlier already but the e2e tests waited for the autopilot to write a new auction to the DB for a readiness check of the autopilot. Since the autopilot is super fast to come online anyway I simply removed the
wait_until_autopilot_readycall.How to test
e2e tests should pass with the change to the readiness check
TODO: some tests now actually fail because the current auction returned by
/auctionnow never becomes empty