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

Commite93a903

Browse files
author
Marina Polyakova
committed
Pgbench Fix TAP tests for retrying failed transactions 2
1 parent3e45d44 commite93a903

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

‎src/bin/pgbench/t/004_retry_failed_transactions.pl

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Config;
55
use PostgresNode;
66
use TestLib;
7-
use Test::Moretests=>37;
7+
use Test::Moretests=>38;
88

99
use constant
1010
{
@@ -35,18 +35,16 @@
3535
my$script1 =$node->basedir .'/pgbench_script1';
3636
append_to_file($script1,
3737
"BEGIN;\n"
38-
."SELECT pg_sleep(10);\n"
3938
."\\set delta1 random(-5000, 5000)\n"
4039
."\\set delta2 random(-5000, 5000)\n"
4140
."UPDATE xy SET y = y + :delta1 WHERE x = 1;\n"
42-
."SELECT pg_sleep(40);\n"
41+
."SELECT pg_sleep(20);\n"
4342
."UPDATE xy SET y = y + :delta2 WHERE x = 2;\n"
4443
."END;");
4544

4645
my$script2 =$node->basedir .'/pgbench_script2';
4746
append_to_file($script2,
4847
"BEGIN;\n"
49-
."SELECT pg_sleep(10);\n"
5048
."\\set delta1 random(-5000, 5000)\n"
5149
."\\set delta2 random(-5000, 5000)\n"
5250
."UPDATE xy SET y = y + :delta2 WHERE x = 2;\n"
@@ -182,9 +180,8 @@ sub test_pgbench_deadlock_failures
182180
print"# Running:" .join("",@command1) ."\n";
183181
$h1 = IPC::Run::start \@command1, \$in1, \$out1, \$err1;
184182

185-
# Let pgbench sleep 10 seconds and run first update command in the
186-
# transaction:
187-
sleep 20;
183+
# Let pgbench run first update command in the transaction:
184+
sleep 10;
188185

189186
# Run second pgbench
190187
my@command2 = (
@@ -258,34 +255,40 @@ sub test_pgbench_deadlock_failures
258255
.": pgbench 2: check deadlock failures");
259256

260257
# First or second pgbench should get a deadlock error
261-
my$pattern =
262-
"client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
263-
."client 0 receiving\n"
264-
."(|client 0 sending SELECT pg_sleep\\(40\\);\n"
265-
."client 0 receiving\n)"
266-
."client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
267-
."client 0 receiving\n"
268-
."client 0 got a deadlock failure\\(attempt 1/2\\)\n"
269-
."client 0 sending END;\n"
270-
."client 0 receiving\n"
271-
."client 0 repeats the failed transaction\\(attempt 2/2\\)\n"
272-
."client 0 sending BEGIN;\n"
273-
."client 0 receiving\n"
274-
."client 0 sending SELECT pg_sleep\\(10\\);\n"
275-
."client 0 receiving\n"
276-
."client 0 executing\\\\set delta1\n"
277-
."client 0 executing\\\\set delta2\n"
278-
."client 0 sending UPDATE xy SET y = y\\+\\g1 WHERE x =\\g2;\n"
279-
."client 0 receiving\n"
280-
."\\g3"
281-
."client 0 sending UPDATE xy SET y = y\\+\\g4 WHERE x =\\g5;\n";
282-
283258
like($err1 .$err2,
284-
qr{$pattern},
259+
qr{client 0 got a deadlock failure},
285260
"concurrent deadlock update with retrying:"
286261
.$isolation_level_sql
287-
.": check the retried transaction");
288-
262+
.": check deadlock failure in debug logs");
263+
264+
if ($isolation_level == READ_COMMITTED)
265+
{
266+
my$pattern =
267+
"client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
268+
."client 0 receiving\n"
269+
."(|client 0 sending SELECT pg_sleep\\(20\\);\n"
270+
."client 0 receiving\n)"
271+
."client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
272+
."client 0 receiving\n"
273+
."client 0 got a deadlock failure\\(attempt 1/2\\)\n"
274+
."client 0 sending END;\n"
275+
."client 0 receiving\n"
276+
."client 0 repeats the failed transaction\\(attempt 2/2\\)\n"
277+
."client 0 sending BEGIN;\n"
278+
."client 0 receiving\n"
279+
."client 0 executing\\\\set delta1\n"
280+
."client 0 executing\\\\set delta2\n"
281+
."client 0 sending UPDATE xy SET y = y\\+\\g1 WHERE x =\\g2;\n"
282+
."client 0 receiving\n"
283+
."\\g3"
284+
."client 0 sending UPDATE xy SET y = y\\+\\g4 WHERE x =\\g5;\n";
285+
286+
like($err1 .$err2,
287+
qr{$pattern},
288+
"concurrent deadlock update with retrying:"
289+
.$isolation_level_sql
290+
.": check the retried transaction");
291+
}
289292
}
290293

291294
test_pgbench_serialization_failures(REPEATABLE_READ);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp