Re: [Patch] ALTER SYSTEM READ ONLY
От | Amul Sul |
---|---|
Тема | Re: [Patch] ALTER SYSTEM READ ONLY |
Дата | |
Msg-id | CAAJ_b97=w0aoHevUcnJK3LBxYTiPgLkbcWZE5ASDYZxo9teR9w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [Patch] ALTER SYSTEM READ ONLY (Mark Dilger <mark.dilger@enterprisedb.com>) |
Ответы |
Re: [Patch] ALTER SYSTEM READ ONLY
(Mark Dilger <mark.dilger@enterprisedb.com>)
|
Список | pgsql-hackers |
On Wed, Sep 22, 2021 at 6:59 PM Mark Dilger <mark.dilger@enterprisedb.com> wrote: > > > > > On Sep 22, 2021, at 6:14 AM, Amul Sul <sulamul@gmail.com> wrote: > > > >> Attached patch v34-0010 adds a test of cursors opened FOR UPDATE interacting with a system that is set read-only bya different session. The expected output is worth reviewing to see how this plays out. I don't see anything in therewhich is obviously wrong, but some of it is a bit clunky. For example, by the time the client sees an error "FATAL: WAL is now prohibited", the system may already have switched back to read-write. Also, it is a bit strange to getone of these errors on an attempted ROLLBACK. Once again, not wrong as such, but clunky. > >> > > > > Can't we do the same in the TAP test? If the intention is only to test > > session termination when the system changes to WAL are prohibited then > > that I have added in the latest version, but that test does not > > reinitiate the same connection again, I think that is not possible > > there too. > > Perhaps you can point me to a TAP test that does this in a concise fashion. When I tried writing a TAP test for this,it was much longer than the equivalent isolation test spec. > Yes, that is a bit longer, here is the snip from v35-0010 patch: +my $psql_timeout = IPC::Run::timer(60); +my ($mysession_stdin, $mysession_stdout, $mysession_stderr) = ('', '', ''); +my $mysession = IPC::Run::start( + [ + 'psql', '-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-f', '-', '-d', + $node_primary->connstr('postgres') + ], + '<', + \$mysession_stdin, + '>', + \$mysession_stdout, + '2>', + \$mysession_stderr, + $psql_timeout); + +# Write in transaction and get backend pid +$mysession_stdin .= q[ +BEGIN; +INSERT INTO tab VALUES(7); +SELECT $$value-7-inserted-into-tab$$; +]; +$mysession->pump until $mysession_stdout =~ /value-7-inserted-into-tab[\r\n]$/; +like($mysession_stdout, qr/value-7-inserted-into-tab/, + 'started write transaction in a session'); +$mysession_stdout = ''; +$mysession_stderr = ''; + +# Change to WAL prohibited +$node_primary->safe_psql('postgres', 'SELECT pg_prohibit_wal(true)'); +is($node_primary->safe_psql('postgres', $show_wal_prohibited_query), 'on', + 'server is changed to wal prohibited by another session'); + +# Try to commit open write transaction. +$mysession_stdin .= q[ +COMMIT; +]; +$mysession->pump; +like($mysession_stderr, qr/FATAL: WAL is now prohibited/, + 'session with open write transaction is terminated'); Regards, Amul
В списке pgsql-hackers по дате отправления: