|
21 | 21 | my $shard1 = get_new_node("shard1"); |
22 | 22 | $shard1->init; |
23 | 23 | $shard1->append_conf('postgresql.conf', qq( |
| 24 | + track_global_snapshots = on |
24 | 25 | max_prepared_transactions = 30 |
25 | 26 | log_checkpoints = true |
26 | 27 | )); |
|
29 | 30 | my $shard2 = get_new_node("shard2"); |
30 | 31 | $shard2->init; |
31 | 32 | $shard2->append_conf('postgresql.conf', qq( |
| 33 | + track_global_snapshots = on |
32 | 34 | max_prepared_transactions = 30 |
33 | 35 | log_checkpoints = true |
34 | 36 | )); |
35 | 37 | $shard2->start; |
36 | 38 |
|
37 | 39 | ############################################################################### |
38 | 40 |
|
39 | | -$master->psql('postgres', "CREATE EXTENSION postgres_fdw"); |
40 | | -$master->psql('postgres', "CREATE TABLE accounts(id integer primary key, amount integer)"); |
| 41 | +$master->safe_psql('postgres', "CREATE EXTENSION postgres_fdw"); |
| 42 | +$master->safe_psql('postgres', "CREATE TABLE accounts(id integer primary key, amount integer)"); |
41 | 43 |
|
42 | 44 | foreach my $node ($shard1, $shard2) |
43 | 45 | { |
44 | 46 | my $port = $node->port; |
45 | 47 | my $host = $node->host; |
46 | 48 |
|
47 | | - # $node->psql('postgres', "CREATE EXTENSION pg_tsdtm"); |
48 | | - $node->psql('postgres', "CREATE TABLE accounts(id integer primary key, amount integer)"); |
| 49 | + $node->safe_psql('postgres', "CREATE TABLE accounts(id integer primary key, amount integer)"); |
49 | 50 |
|
50 | | - $master->psql('postgres', "CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')"); |
51 | | - $master->psql('postgres', "CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')"); |
52 | | - my $me = scalar(getpwuid($<)); |
53 | | - $master->psql('postgres', "CREATE USER MAPPING for $me SERVER shard_$port options (user '$me')"); |
| 51 | + $master->safe_psql('postgres', "CREATE SERVER shard_$port FOREIGN DATA WRAPPER postgres_fdw options(dbname 'postgres', host '$host', port '$port')"); |
| 52 | + $master->safe_psql('postgres', "CREATE FOREIGN TABLE accounts_fdw_$port() inherits (accounts) server shard_$port options(table_name 'accounts')"); |
| 53 | + $master->safe_psql('postgres', "CREATE USER MAPPING for CURRENT_USER SERVER shard_$port"); |
54 | 54 |
|
55 | 55 | # diag("done $host $port"); |
56 | 56 | } |
57 | 57 |
|
58 | | -$shard1->psql('postgres', "insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;"); |
59 | | -$shard2->psql('postgres', "insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;"); |
| 58 | +$shard1->safe_psql('postgres', "insert into accounts select 2*id-1, 0 from generate_series(1, 10010) as id;"); |
| 59 | +$shard2->safe_psql('postgres', "insert into accounts select 2*id, 0 from generate_series(1, 10010) as id;"); |
60 | 60 |
|
61 | 61 | # diag( $master->connstr() ); |
62 | 62 | # sleep(3600); |
|
76 | 76 | my $started = time(); |
77 | 77 | while (time() - $started < $seconds) |
78 | 78 | { |
79 | | - ($rc, $total, $err) = $master->psql('postgres', "select sum(amount) from accounts"); |
| 79 | + ($rc, $total, $err) = $master->safe_psql('postgres', "select sum(amount) from accounts"); |
80 | 80 | if ( ($total ne $oldtotal) and ($total ne '') ) |
81 | 81 | { |
82 | 82 | $isolation_error = 1; |
|
0 commit comments