Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit991bb0f

Browse files
committed
worker_spi: Add tests for BGWORKER_BYPASS_ALLOWCONN
This bgworker flag exists in the core code sinceeed1ce7, but wasnever tested. This relies on4f29946, that has added a way tostart dynamic workers with this flag enabled.Reviewed-by: Bertrand Drouvot, Bharath RupireddyDiscussion:https://postgr.es/m/bcc36259-7850-4882-97ef-d6b905d2fc51@gmail.com
1 parent180e339 commit991bb0f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎src/test/modules/worker_spi/t/001_worker_spi.pl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,31 @@
104104
'dynamic bgworkers all launched'
105105
)ordie"Timed out while waiting for dynamic bgworkers to be launched";
106106

107+
# Check BGWORKER_BYPASS_ALLOWCONN.
108+
$node->safe_psql('postgres',q(ALTER DATABASE mydb ALLOW_CONNECTIONS false;));
109+
my$log_offset =-s$node->logfile;
110+
111+
# bgworker cannot be launched with connection restriction.
112+
my$worker3_pid =$node->safe_psql('postgres',
113+
qq[SELECT worker_spi_launch(12,$mydb_id,$myrole_id);]);
114+
$node->wait_for_log(
115+
qr/database "mydb" is not currently accepting connections/,$log_offset);
116+
117+
$result =$node->safe_psql('postgres',
118+
"SELECT count(*) FROM pg_stat_activity WHERE pid =$worker3_pid;");
119+
is($result,'0','dynamic bgworker without BYPASS_ALLOWCONN not started');
120+
121+
# bgworker bypasses the connection check, and can be launched.
122+
my$worker4_pid =$node->safe_psql('postgres',
123+
qq[SELECT worker_spi_launch(12,$mydb_id,$myrole_id, '{"ALLOWCONN"}');]);
124+
ok($node->poll_query_until(
125+
'postgres',
126+
qq[SELECT datname, usename, wait_event FROM pg_stat_activity
127+
WHERE backend_type = 'worker_spi dynamic' AND
128+
pid IN ($worker4_pid) ORDER BY datname;],
129+
qq[mydb|myrole|WorkerSpiMain]),
130+
'dynamic bgworker with BYPASS_ALLOWCONN started');
131+
132+
$node->safe_psql('postgres',q(ALTER DATABASE mydb ALLOW_CONNECTIONS true;));
133+
107134
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp