|
4 | 4 | use Config;
|
5 | 5 | use PostgresNode;
|
6 | 6 | use TestLib;
|
7 |
| -use Test::Moretests=>58; |
| 7 | +use Test::Moretests=>63; |
8 | 8 |
|
9 | 9 | use constant
|
10 | 10 | {
|
|
38 | 38 | ."\\set delta1 random(-5000, 5000)\n"
|
39 | 39 | ."\\set delta2 random(-5000, 5000)\n"
|
40 | 40 | ."UPDATE xy SET y = y + :delta1 WHERE x = 1;\n"
|
41 |
| - ."SELECT pg_sleep(20);\n" |
| 41 | + ."SELECT pg_sleep(60);\n" |
42 | 42 | ."UPDATE xy SET y = y + :delta2 WHERE x = 2;\n"
|
43 | 43 | ."END;");
|
44 | 44 |
|
@@ -87,7 +87,7 @@ sub test_pgbench_default_transaction_isolation_level_and_serialization_failures
|
87 | 87 | \$err_pgbench;
|
88 | 88 |
|
89 | 89 | # Let pgbench run the update command in the transaction:
|
90 |
| -sleep10; |
| 90 | +sleep30; |
91 | 91 |
|
92 | 92 | # In psql, commit the transaction and end the session:
|
93 | 93 | $in_psql ="end;\n";
|
@@ -183,7 +183,7 @@ sub test_pgbench_serialization_failures_retry
|
183 | 183 | \$stderr;
|
184 | 184 |
|
185 | 185 | # Let pgbench run the update command in the transaction:
|
186 |
| -sleep10; |
| 186 | +sleep30; |
187 | 187 |
|
188 | 188 | # In psql, commit the transaction and end the session:
|
189 | 189 | $in_psql ="end;\n";
|
@@ -269,7 +269,7 @@ sub test_pgbench_deadlock_failures
|
269 | 269 | $h1 = IPC::Run::start \@command1, \$in1, \$out1, \$err1;
|
270 | 270 |
|
271 | 271 | # Let pgbench run first update command in the transaction:
|
272 |
| -sleep10; |
| 272 | +sleep30; |
273 | 273 |
|
274 | 274 | # Run second pgbench
|
275 | 275 | my@command2 = (
|
@@ -357,7 +357,7 @@ sub test_pgbench_deadlock_failures_retry
|
357 | 357 | $h1 = IPC::Run::start \@command1, \$in1, \$out1, \$err1;
|
358 | 358 |
|
359 | 359 | # Let pgbench run first update command in the transaction:
|
360 |
| -sleep10; |
| 360 | +sleep30; |
361 | 361 |
|
362 | 362 | # Run second pgbench
|
363 | 363 | my@command2 = (
|
@@ -408,26 +408,33 @@ sub test_pgbench_deadlock_failures_retry
|
408 | 408 | .$isolation_level_sql
|
409 | 409 | .": pgbench 2: check processed transactions");
|
410 | 410 |
|
411 |
| -# First or second pgbench should get a deadlock error |
| 411 | +# First or second pgbench should get a deadlock error which was retried |
412 | 412 | like($err1 .$err2,
|
413 | 413 | qr{client 0 got a deadlock failure\(try 1/2\)},
|
414 | 414 | "concurrent deadlock update with retrying:"
|
415 | 415 | .$isolation_level_sql
|
416 | 416 | .": check deadlock failure");
|
417 | 417 |
|
| 418 | +like($out1 .$out2, |
| 419 | +qr{number of transactions retried: 1\(100.000 %\)}, |
| 420 | +"concurrent deadlock update with retrying:" |
| 421 | + .$isolation_level_sql |
| 422 | + .": check retried transactions"); |
| 423 | + |
| 424 | +like($out1 .$out2, |
| 425 | +qr{number of retries: 1\(serialization: 0, deadlocks: 1\)}, |
| 426 | +"concurrent deadlock update with retrying:" |
| 427 | + .$isolation_level_sql |
| 428 | + .": check retries"); |
| 429 | + |
418 | 430 | if ($isolation_level == READ_COMMITTED)
|
419 | 431 | {
|
420 | 432 | # At other isolation levels, there may be serialization failures
|
421 |
| -like($out1 .$out2, |
422 |
| -qr{^((?!number of failures)(.|\n))*$}, |
423 |
| -"concurrent deadlock update with retrying:" |
424 |
| - .$isolation_level_sql |
425 |
| - .": check failures"); |
426 | 433 |
|
427 | 434 | my$pattern =
|
428 | 435 | "client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
|
429 | 436 | ."(client 0 receiving\n)+"
|
430 |
| - ."(|client 0 sending SELECT pg_sleep\\(20\\);\n)" |
| 437 | + ."(|client 0 sending SELECT pg_sleep\\(60\\);\n)" |
431 | 438 | ."\\g3*"
|
432 | 439 | ."client 0 sending UPDATE xy SET y = y\\+ (-?\\d+) WHERE x = (\\d);\n"
|
433 | 440 | ."\\g3+"
|
|