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(pgdriver): Implement database/sql/driver.SessionResetter #635

Merged
merged 2 commits into from
Aug 1, 2022
Merged

feat(pgdriver): Implement database/sql/driver.SessionResetter #635

merged 2 commits into from
Aug 1, 2022

Conversation

htdvisser
Copy link
Contributor

This pull request implements the SessionResetter interface on pgdriver.Conn.

The SessionResetter can be useful to detect a closed or bad connection before we're trying to run queries on it. To make this work, we'd need some way to get the underlying net.Conn from *pgdriver.Conn, so I added a Conn() net.Conn method for that. This is similar to how *pgx.Conn lets you get the underlying *pgconn.PgConn.

@vmihailenco vmihailenco merged commit f2f4149 into uptrace:master Aug 1, 2022
@vmihailenco
Copy link
Member

Thanks

@htdvisser htdvisser deleted the feature/reset-session branch August 1, 2022 15:38
@NirBarak-RecoLabs
Copy link

Just wanted to give a thumbs up - if I understand correctly this is the perfect solution for multi-tenancy. Since you already have an exclusive lock on the connection when the SessionResetter is called, you can apply row-level security on the connection immediately before the query is called.

Seems like an undervalued feature to me - it has great potential!

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.

None yet

3 participants