-
Notifications
You must be signed in to change notification settings - Fork 55
feat: side-effect SELECT #158
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
// Check for side-effect functions in the target list | ||
if Self::has_side_effect_function(stmt) { | ||
debug!("Query contains side-effect function, routing to primary."); | ||
return Ok(Command::Query(Route::write(None))); |
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.
This makes it a cross-shard query. I don't think we want that, necessarily, especially for advisory locks. You'd probably want to pick a shard that handles it, since advisory locks on different shards won't actually mutually exclude queries.
Unfortunately despite I think this is due to the fact that the lock can't be acquired - but I wasn't able to find any additional information on the real reason this happens. From a code perspective, I don't see why my approach shouldn't work (tried both by sending to all instances and to just one shard). Any tip is appreciated - I would really love to use pgdog so that I can load-balance Immich. |
Cool, I will take a look! |
Haven't forgotten about this, just trying to find the time. Sorry for the delay. |
Fixes #134.
FYI: This is just an attempt at fixing the issue - I'm by no means a PostgreSQL expert, and I've used Claude 3.7 Sonnet + Gemini 2.5 Pro to come up with a somewhat working solution.
I'll test this further before marking it as "Ready to Review"