File: parallel.out

package info (click to toggle)
pglogical 2.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,236 kB
  • sloc: ansic: 39,239; sql: 4,466; perl: 693; makefile: 210; sh: 77
file content (188 lines) | stat: -rw-r--r-- 5,860 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
SELECT * FROM pglogical_regress_variables()
\gset
\c :provider_dsn
SELECT * FROM pglogical.create_replication_set('parallel');
 create_replication_set 
------------------------
             3731651575
(1 row)

\c :subscriber_dsn
SELECT * FROM pglogical.create_subscription(
    subscription_name := 'test_subscription_parallel',
    provider_dsn := (SELECT provider_dsn FROM pglogical_regress_variables()) || ' user=super',
	replication_sets := '{parallel,default}',
	forward_origins := '{}',
	synchronize_structure := false,
	synchronize_data := false
);
ERROR:  existing subscription "test_subscription" to node "test_provider" already subscribes to replication set "default"
SELECT * FROM pglogical.create_subscription(
    subscription_name := 'test_subscription_parallel',
    provider_dsn := (SELECT provider_dsn FROM pglogical_regress_variables()) || ' user=super',
	replication_sets := '{parallel}',
	forward_origins := '{}',
	synchronize_structure := false,
	synchronize_data := false
);
 create_subscription 
---------------------
          4051189029
(1 row)

BEGIN;
SET LOCAL statement_timeout = '180s';
SELECT pglogical.wait_for_subscription_sync_complete('test_subscription_parallel');
 wait_for_subscription_sync_complete 
-------------------------------------
 
(1 row)

COMMIT;
SELECT sync_kind, sync_subid, sync_nspname, sync_relname, sync_status IN ('y', 'r') FROM pglogical.local_sync_status ORDER BY 2,3,4;
 sync_kind | sync_subid | sync_nspname | sync_relname | ?column? 
-----------+------------+--------------+--------------+----------
 f         | 3848008564 |              |              | t
 i         | 4051189029 |              |              | t
(2 rows)

SELECT * FROM pglogical.show_subscription_status();
     subscription_name      |   status    | provider_node |         provider_dsn         |                 slot_name                  |           replication_sets            | forward_origins 
----------------------------+-------------+---------------+------------------------------+--------------------------------------------+---------------------------------------+-----------------
 test_subscription          | replicating | test_provider | dbname=regression user=super | pgl_postgres_test_provider_test_sube55bf37 | {default,default_insert_only,ddl_sql} | 
 test_subscription_parallel | replicating | test_provider | dbname=regression user=super | pgl_postgres_test_provider_test_subf1783d2 | {parallel}                            | 
(2 rows)

-- Make sure we see the slot and active connection
\c :provider_dsn
SELECT plugin, slot_type, database, active FROM pg_replication_slots;
      plugin      | slot_type |  database  | active 
------------------+-----------+------------+--------
 pglogical_output | logical   | regression | t
 pglogical_output | logical   | regression | t
(2 rows)

SELECT count(*) FROM pg_stat_replication;
 count 
-------
     2
(1 row)

SELECT pglogical.replicate_ddl_command($$
    CREATE TABLE public.basic_dml1 (
        id serial primary key,
        other integer,
        data text,
        something interval
    );
    CREATE TABLE public.basic_dml2 (
        id serial primary key,
        other integer,
        data text,
        something interval
    );
$$);
 replicate_ddl_command 
-----------------------
 t
(1 row)

SELECT * FROM pglogical.replication_set_add_table('default', 'basic_dml1');
 replication_set_add_table 
---------------------------
 t
(1 row)

SELECT * FROM pglogical.replication_set_add_table('parallel', 'basic_dml2');
 replication_set_add_table 
---------------------------
 t
(1 row)

SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

WITH one AS (
INSERT INTO basic_dml1(other, data, something)
VALUES (5, 'foo', '1 minute'::interval),
       (4, 'bar', '12 weeks'::interval),
       (3, 'baz', '2 years 1 hour'::interval),
       (2, 'qux', '8 months 2 days'::interval),
       (1, NULL, NULL)
RETURNING *
)
INSERT INTO basic_dml2 SELECT * FROM one;
BEGIN;
UPDATE basic_dml1 SET other = id, something = something - '10 seconds'::interval WHERE id < 3;
DELETE FROM basic_dml2 WHERE id < 3;
COMMIT;
SELECT pglogical.wait_slot_confirm_lsn(NULL, NULL);
 wait_slot_confirm_lsn 
-----------------------
 
(1 row)

SELECT * FROM basic_dml1;
 id | other | data |     something      
----+-------+------+--------------------
  3 |     3 | baz  | @ 2 years 1 hour
  4 |     2 | qux  | @ 8 mons 2 days
  5 |     1 |      | 
  1 |     1 | foo  | @ 50 secs
  2 |     2 | bar  | @ 84 days -10 secs
(5 rows)

SELECT * FROM basic_dml2;
 id | other | data |    something     
----+-------+------+------------------
  3 |     3 | baz  | @ 2 years 1 hour
  4 |     2 | qux  | @ 8 mons 2 days
  5 |     1 |      | 
(3 rows)

\c :subscriber_dsn
SELECT * FROM basic_dml1;
 id | other | data |     something      
----+-------+------+--------------------
  3 |     3 | baz  | @ 2 years 1 hour
  4 |     2 | qux  | @ 8 mons 2 days
  5 |     1 |      | 
  1 |     1 | foo  | @ 50 secs
  2 |     2 | bar  | @ 84 days -10 secs
(5 rows)

SELECT * FROM basic_dml2;
 id | other | data |    something     
----+-------+------+------------------
  3 |     3 | baz  | @ 2 years 1 hour
  4 |     2 | qux  | @ 8 mons 2 days
  5 |     1 |      | 
(3 rows)

SELECT pglogical.drop_subscription('test_subscription_parallel');
 drop_subscription 
-------------------
                 1
(1 row)

\c :provider_dsn
\set VERBOSITY terse
SELECT * FROM pglogical.drop_replication_set('parallel');
 drop_replication_set 
----------------------
 t
(1 row)

SELECT pglogical.replicate_ddl_command($$
    DROP TABLE public.basic_dml1 CASCADE;
    DROP TABLE public.basic_dml2 CASCADE;
$$);
NOTICE:  drop cascades to table public.basic_dml1 membership in replication set default
 replicate_ddl_command 
-----------------------
 t
(1 row)