pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTransaction prevention
4+ messages / 2 participants
[nested] [flat]
* Transaction prevention
@ 2020-07-29 23:56 Steve Baldwin <steve.baldwin@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Steve Baldwin @ 2020-07-29 23:56 UTC (permalink / raw)
To: pgsql-general
Hi,
If I have a user that is restricted to select access (only) on a single
table, is there any way to prevent that user from starting a transaction?
The reason for the question is that the select-only user can block another
session trying to run an alter table on that table if the select-only
user runs their query in a transaction.
This happened to us recently where a migration script that was being run
during a ci deployment 'hung' until the select-only user happened to
disconnect. I'm wondering if we need to terminate any sessions from
select-only users at the start of the migration, or if there is a better
way.
Thanks,
Steve
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Transaction prevention
@ 2020-07-30 00:23 Tom Lane <tgl@sss.pgh.pa.us>
parent: Steve Baldwin <steve.baldwin@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2020-07-30 00:23 UTC (permalink / raw)
To: Steve Baldwin <steve.baldwin@gmail.com>; +Cc: pgsql-general
Steve Baldwin <steve.baldwin@gmail.com> writes:
> If I have a user that is restricted to select access (only) on a single
> table, is there any way to prevent that user from starting a transaction?
No, but maybe setting statement_timeout and/or
idle_in_transaction_session_timeout for that user would be helpful
(cf ALTER USER ... SET ...).
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Transaction prevention
@ 2020-07-30 00:50 Steve Baldwin <steve.baldwin@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Steve Baldwin @ 2020-07-30 00:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general
Thanks Tom. The idle_in_transaction_session_timeout could work well, but it
seems to be just a default that can be overridden by a user post-login (or
am I missing something?). I'm thinking of setting lock_timeout as part of
the migration process so it will fail if it is unable to obtain a lock in a
'reasonable' amount of time. I wonder what other folks do?
Cheers,
Steve
On Thu, Jul 30, 2020 at 10:23 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Steve Baldwin <steve.baldwin@gmail.com> writes:
> > If I have a user that is restricted to select access (only) on a single
> > table, is there any way to prevent that user from starting a transaction?
>
> No, but maybe setting statement_timeout and/or
> idle_in_transaction_session_timeout for that user would be helpful
> (cf ALTER USER ... SET ...).
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Transaction prevention
@ 2020-07-30 01:10 Tom Lane <tgl@sss.pgh.pa.us>
parent: Steve Baldwin <steve.baldwin@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2020-07-30 01:10 UTC (permalink / raw)
To: Steve Baldwin <steve.baldwin@gmail.com>; +Cc: pgsql-general
Steve Baldwin <steve.baldwin@gmail.com> writes:
> Thanks Tom. The idle_in_transaction_session_timeout could work well, but it
> seems to be just a default that can be overridden by a user post-login (or
> am I missing something?).
It is that, but if you have an actively malicious user then you need to
keep them from issuing SQL directly at all. There are far too many ways
to cause effective denial-of-service, eg a single query that runs
"forever".
> I'm thinking of setting lock_timeout as part of
> the migration process so it will fail if it is unable to obtain a lock in a
> 'reasonable' amount of time. I wonder what other folks do?
If you'd rather fail the migration process, sure.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-07-30 01:10 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 23:56 Transaction prevention Steve Baldwin <steve.baldwin@gmail.com>
2020-07-30 00:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-07-30 00:50 ` Steve Baldwin <steve.baldwin@gmail.com>
2020-07-30 01:10 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox