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

feat(postgres): add PgAdvisoryLockGuardOwned #3442

Closed
wants to merge 1 commit into from

Conversation

bonsairobo
Copy link

This new lock guard can own an Arc<PgAdvisoryLock> without any lifetime, allowing it to be moved into spawned tasks.

Fixes #3429

This new lock guard can own an `Arc<PgAdvisoryLock>` without any lifetime,
allowing it to be moved into spawned tasks.
@abonander
Copy link
Collaborator

@bonsairobo (moving the design discussion here)

Re: #3429 (comment)

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.

@bonsairobo
Copy link
Author

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.

@abonander
Copy link
Collaborator

If you'd like to make those changes then, I'll tag this as Breaking.

@bonsairobo
Copy link
Author

Superseded by #3495

@bonsairobo bonsairobo closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AdvisoryLockGuard without lifetime
2 participants