Skip to content
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

try to avoid some locking #17566

Closed
wants to merge 5 commits into from
Closed

try to avoid some locking #17566

wants to merge 5 commits into from

Conversation

zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented Mar 22, 2025

[wip] reduce SQLite locking

not sure about this yet, just looking for now

for example: i saw that worker heartbeats could trigger "database is locked" errors when using SQLite, which seems related to serialization during work pool status transitions.

this pr

  • updates work pool status transition in worker_heartbeat by only acquiring lock when needed
  • adds with_for_update=True in a flow run read and a work pool query to ensure atomic operations (TODO revisit)

an assumption im making is that we only need to serialize access when actually changing a work pool's status from NOT_READY to READY - the worker heartbeat upsert itself uses on_conflict_do_update

(maybe) consider logfire for exploring bottlenecks

i am not suggesting i commit this optional logfire instrumentation as is, though would be open to putting it behind a real flag if we eventually had buy in
image

related to #16299

Copy link

codspeed-hq bot commented Mar 22, 2025

CodSpeed Performance Report

Merging #17566 will not alter performance

Comparing perf (5c386bf) with main (007ef06)

Summary

✅ 2 untouched benchmarks

pyright
@zzstoatzz zzstoatzz added the performance Related to an optimization or performance improvement label Mar 22, 2025
@zzstoatzz zzstoatzz changed the title avoid locking try to avoid some locking Mar 22, 2025
@zzstoatzz zzstoatzz closed this Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Related to an optimization or performance improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant