Closed bonsairobo closed 3 weeks ago
@bonsairobo (moving the design discussion here)
Re: https://github.com/launchbadge/sqlx/issues/3429#issuecomment-2295471364
Is this an optimization to avoid deeply cloning the
AdvisoryLock
?
The only thing is the memoization of the release query: https://github.com/launchbadge/sqlx/blob/main/sqlx-postgres/src/advisory_lock.rs#L40
Which isn't strictly necessary I suppose. I was trying to amortize the allocation but at the end of the day it's going to be copied into the connection's buffer anyway.
I'm not against just making the guard not borrow the lock anymore, but it'd be a breaking change to remove the lifetime parameter so it would have to wait for 0.9.0 if we went that route.
I'm not against just making the guard not borrow the lock anymore, but it'd be a breaking change to remove the lifetime parameter so it would have to wait for 0.9.0 if we went that route.
That would be my preference. I'm OK to wait for a release.
If you'd like to make those changes then, I'll tag this as Breaking.
Superseded by https://github.com/launchbadge/sqlx/pull/3495
This new lock guard can own an
Arc<PgAdvisoryLock>
without any lifetime, allowing it to be moved into spawned tasks.Fixes #3429