Skip to content

Only generate new auction_id for non-empty auctions#4314

Draft
MartinquaXD wants to merge 4 commits intomainfrom
only-increase-auction-id-for-non-empty-auctions
Draft

Only generate new auction_id for non-empty auctions#4314
MartinquaXD wants to merge 4 commits intomainfrom
only-increase-auction-id-for-non-empty-auctions

Conversation

@MartinquaXD
Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD commented Apr 7, 2026

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_ready call.

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 /auction now never becomes empty

@MartinquaXD MartinquaXD requested a review from a team as a code owner April 7, 2026 20:31
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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
  1. For integration tests, prioritize CI stability by ensuring robust synchronization and handling potential environment-related delays gracefully.

@MartinquaXD MartinquaXD marked this pull request as draft April 7, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant