Skip to content

autopilot: don't fetch DB while holding the lock#4604

Open
ueco-jb wants to merge 1 commit into
cowprotocol:mainfrom
ueco-jb:main
Open

autopilot: don't fetch DB while holding the lock#4604
ueco-jb wants to merge 1 commit into
cowprotocol:mainfrom
ueco-jb:main

Conversation

@ueco-jb

@ueco-jb ueco-jb commented Jul 6, 2026

Copy link
Copy Markdown

Description

While scoping the repo I noticed that this particular comment was contradicting the actual code.
get_solvable_orders acquired the cache Mutex and held the guard across the DB fetch, instead of awaiting without a lock.

Changes

Scope the guard to a block so it's released the instant the future is built.

How to test

Tests from autopilot crate are passing, the behavior is preserved - identical SolvableOrders are returned. Only the guard's lifetime shrank.

Related Issues

Fixes #

@ueco-jb ueco-jb requested a review from a team as a code owner July 6, 2026 15:38
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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

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.

Code Review

This pull request refactors the cache locking mechanism in solvable_orders.rs by wrapping the lock acquisition and query building inside a block. This ensures that the cache lock is dropped before the fetch_orders future is awaited, preventing potential lock contention or deadlocks. No critical issues were found, and there is no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@ueco-jb ueco-jb changed the title SolvableOrdersCache: only build future while holding the lock autopilot: don't fetch DB while holding the lock Jul 6, 2026
@ueco-jb

ueco-jb commented Jul 6, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 6, 2026
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.

2 participants