Skip to content

Commit a6285b1

Browse files
committed
tests: Fix incompatibility of test_aio with *_FORCE_RELEASE
The test added in 93bc3d7 failed in a build with RELCACHE_FORCE_RELEASE and CATCACHE_FORCE_RELEASE defined. The test intentionally forgets to exit batchmode - normally that would trigger an error at the end of the transaction, which the test verifies. However, with RELCACHE_FORCE_RELEASE and CATCACHE_FORCE_RELEASE defined, we get other code (output function lookup) entering batchmode and erroring out because batchmode isn't allowed to be entered recursively. Fix that by changing the queries in question to not output any rows. That's not exactly pretty, but seems to avoid the problem reliably. Eventually we might want to make RELCACHE_FORCE_RELEASE and CATCACHE_FORCE_RELEASE GUCs, so we can disable them where necessary - this isn't the first test having difficulty with those debug options. But that's for later. Per buildfarm member prion. Discussion: https://postgr.es/m/uc62i6vi5gd4bi6wtjj5poadqxolgy55e7ihkmf3mthjegb6zl@zqo7xez7sc2r
1 parent 43dca8a commit a6285b1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/test/modules/test_aio/t/001_aio.pl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,18 @@ sub test_batchmode
325325

326326
my $psql = $node->background_psql('postgres', on_error_stop => 0);
327327

328+
# In a build with RELCACHE_FORCE_RELEASE and CATCACHE_FORCE_RELEASE, just
329+
# using SELECT batch_start() causes spurious test failures, because the
330+
# lookup of the type information when printing the result tuple also
331+
# starts a batch. The easiest way around is to not print a result tuple.
332+
my $batch_start_sql = qq(SELECT WHERE batch_start() IS NULL);
333+
328334
# leak warning & recovery: implicit xact
329335
psql_like(
330336
$io_method,
331337
$psql,
332338
"batch_start() leak & cleanup in implicit xact",
333-
qq(SELECT batch_start()),
339+
$batch_start_sql,
334340
qr/^$/,
335341
qr/open AIO batch at end/,
336342
"$io_method: leaky batch_start() warns");
@@ -340,7 +346,7 @@ sub test_batchmode
340346
$io_method,
341347
$psql,
342348
"batch_start() leak & cleanup in explicit xact",
343-
qq(BEGIN; SELECT batch_start(); COMMIT;),
349+
qq(BEGIN; $batch_start_sql; COMMIT;),
344350
qr/^$/,
345351
qr/open AIO batch at end/,
346352
"$io_method: leaky batch_start() warns");
@@ -353,7 +359,7 @@ sub test_batchmode
353359
# it just means it's a bit harder to find buggy code.
354360
#psql_like($io_method, $psql,
355361
# "batch_start() leak & cleanup after abort",
356-
# qq(BEGIN; SELECT batch_start(); ROLLBACK;),
362+
# qq(BEGIN; $batch_start_sql; ROLLBACK;),
357363
# qr/^$/,
358364
# qr/open AIO batch at end/, "$io_method: leaky batch_start() warns");
359365

@@ -362,7 +368,7 @@ sub test_batchmode
362368
$io_method,
363369
$psql,
364370
"batch_start(), batch_end() works",
365-
qq(SELECT batch_start() UNION ALL SELECT batch_end()),
371+
qq($batch_start_sql UNION ALL SELECT WHERE batch_end() IS NULL),
366372
qr/^$/,
367373
qr/^$/,
368374
"$io_method: batch_start(), batch_end()");

0 commit comments

Comments
 (0)