Skip to content

Commit

Permalink
Merge branch 'pglogical2-fix-revert' into REL2_x_STABLE
Browse files Browse the repository at this point in the history
This reverts several problematic changes introduced between 2.2.2 and
2.3.0.
  • Loading branch information
petere committed Apr 6, 2020
2 parents 1aea9f8 + 9e52a28 commit 19d6f4f
Show file tree
Hide file tree
Showing 44 changed files with 564 additions and 2,156 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ DATA = pglogical--1.0.0.sql pglogical--1.0.0--1.0.1.sql \
pglogical--2.2.0--2.2.1.sql pglogical--2.2.1.sql \
pglogical--2.2.1--2.2.2.sql pglogical--2.2.2.sql \
pglogical--2.2.2--2.3.0.sql \
pglogical--2.3.0.sql
pglogical--2.2.2--2.3.1.sql \
pglogical--2.3.0.sql \
pglogical--2.3.0--2.3.1.sql \
pglogical--2.3.1.sql

OBJS = pglogical_apply.o pglogical_conflict.o pglogical_manager.o \
pglogical.o pglogical_node.o pglogical_relcache.o \
Expand All @@ -34,10 +37,10 @@ OBJS = pglogical_apply.o pglogical_conflict.o pglogical_manager.o \
SCRIPTS_built = pglogical_create_subscriber

REGRESS = preseed infofuncs init_fail init preseed_check basic extended conflict_secondary_unique \
toasted replication_set add_table relations_only matview bidirectional \
primary_key interfaces foreign_key functions copy triggers parallel row_filter \
toasted replication_set add_table matview bidirectional primary_key \
interfaces foreign_key functions copy triggers parallel row_filter \
row_filter_sampling att_list column_filter apply_delay multiple_upstreams \
map node_origin_cascade drop
node_origin_cascade drop

EXTRA_CLEAN += compat94/pglogical_compat.o compat95/pglogical_compat.o \
compat96/pglogical_compat.o compat10/pglogical_compat.o \
Expand Down
39 changes: 6 additions & 33 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Use cases supported are:
* Selective replication of table rows at either publisher or subscriber side (row_filter)
* Selective replication of table columns at publisher side
* Data gather/merge from multiple upstream servers
* Data gather/merge from multiple upstream tables (distinct names)

Architectural details:
* pglogical works on a per-database level, not whole server level like
Expand Down Expand Up @@ -277,21 +276,18 @@ Nodes can be added and removed dynamically using the SQL interfaces.
### Subscription management

- `pglogical.create_subscription(subscription_name name, provider_dsn text,
replication_sets text[], synchronize_structure text(none,all,relations_only),
replication_sets text[], synchronize_structure boolean,
synchronize_data boolean, forward_origins text[], apply_delay interval)`
Creates a subscription from current node to the provider node, with option to
synchronize part or all the structure. Command does not block, just initiates
the action.
Creates a subscription from current node to the provider node. Command does
not block, just initiates the action.

Parameters:
- `subscription_name` - name of the subscription, must be unique
- `provider_dsn` - connection string to a provider
- `replication_sets` - array of replication sets to subscribe to, these must
already exist, default is "{default,default_insert_only,ddl_sql}"
- `synchronize_structure` - specifies if to synchronize structure from
provider to the subscriber, default `none`. `all` for all objects,
`relations_only` for replicated tables and sequences only (in this last case
schemas themselves are not created on the subscriber).
provider to the subscriber, default false
- `synchronize_data` - specifies if to synchronize data from provider to
the subscriber, default true
- `forward_origins` - array of origin names to forward, currently only
Expand All @@ -311,10 +307,6 @@ Nodes can be added and removed dynamically using the SQL interfaces.
pglogical is used as part of
[synchronous replication](#synchronous-replication) setup.

Pglogical currently executes `pg_dump` with a list of `-t TABLE/SEQUENCE`
parameter to synchronize relations only. The limitation of the system apply
and can limit the length of the command line.

Use `pglogical.wait_for_subscription_sync_complete(sub_name)` to wait for the
subscription to asynchronously start replicating and complete any needed
schema and/or data sync.
Expand Down Expand Up @@ -502,7 +494,7 @@ The following functions are provided for managing the replication sets:
Parameters:
- `set_name` - name of the existing replication set

- `pglogical.replication_set_add_table(set_name name, relation regclass, synchronize_data boolean, columns text[], row_filter text, nsptarget text, reltarget text)`
- `pglogical.replication_set_add_table(set_name name, relation regclass, synchronize_data boolean, columns text[], row_filter text)`
Adds a table to replication set.

Parameters:
Expand All @@ -516,8 +508,6 @@ The following functions are provided for managing the replication sets:
- `row_filter` - row filtering expression, default NULL (no filtering),
see [Row Filtering](#row-filtering) for more info.
**WARNING: Use caution when synchronizing data with a valid row filter.**
- `nsptarget` - name of the schema visible to the receiver
- `reltarget` - name of the relation visible to the receiver
Using `synchronize_data=true` with a valid `row_filter` is like a one-time operation for a table.
Executing it again with modified `row_filter` won't synchronize data to subscriber. Subscribers
may need to call `pglogical.alter_subscription_resynchronize_table()` to fix it.
Expand All @@ -542,15 +532,13 @@ may need to call `pglogical.alter_subscription_resynchronize_table()` to fix it.
- `set_name` - name of the existing replication set
- `relation` - name or OID of the table to be removed from the set

- `pglogical.replication_set_add_sequence(set_name name, relation regclass, synchronize_data boolean, nsptarget text, reltarget text)`
- `pglogical.replication_set_add_sequence(set_name name, relation regclass, synchronize_data boolean)`
Adds a sequence to a replication set.

Parameters:
- `set_name` - name of the existing replication set
- `relation` - name or OID of the sequence to be added to the set
- `synchronize_data` - if true, the sequence value will be synchronized immediately, default false
- `nsptarget` - name of the schema visible to the receiver
- `reltarget` - name of the relation visible to the receiver

- `pglogical.replication_set_add_all_sequences(set_name name, schema_names text[], synchronize_data boolean)`
Adds all sequences from the given schemas. Only existing sequences are added, any sequences that
Expand Down Expand Up @@ -660,14 +648,6 @@ It is required to mark any such triggers as either `ENABLE REPLICA` or
`ENABLE ALWAYS` otherwise they will not be executed by the replication
process.

### Table and Sequence renaming

It is possible to set distinct names for schema and/or relations while adding
them to the replication set on the provider side. This way, the receiver does
not know the original name and it's possible to merge 2 and more tables from the
provider to a single table on the receiver, it also allows to "rename" tables
(and sequence) from one side to the other.

## Synchronous Replication

Synchronous replication is supported using same standard mechanism provided
Expand All @@ -678,13 +658,6 @@ when `COMMIT` command reports success to client if pglogical subscription
name is used in `synchronous_standby_names`. Refer to PostgreSQL
documentation for more info about how to configure these two variables.

# Table and Sequence names

By default, relation and schema name are the same on the receiver and the
provider. However 2 columns are used to track the target names to offer the
user to change them, the receiver does not know about the original names,
only those (mandatory) set for "target".

## Conflicts

In case the node is subscribed to multiple providers, or when local writes
Expand Down
2 changes: 1 addition & 1 deletion expected/apply_delay.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SELECT * FROM pglogical.create_subscription(
provider_dsn := (SELECT provider_dsn FROM pglogical_regress_variables()) || ' user=super',
replication_sets := '{delay}',
forward_origins := '{}',
synchronize_structure := 'none',
synchronize_structure := false,
synchronize_data := false,
apply_delay := int2interval(2) -- 2 seconds
);
Expand Down
2 changes: 1 addition & 1 deletion expected/bidirectional.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ END;$$;
SELECT * FROM pglogical.create_subscription(
subscription_name := 'test_bidirectional',
provider_dsn := (SELECT subscriber_dsn FROM pglogical_regress_variables()) || ' user=super',
synchronize_structure := 'none',
synchronize_structure := false,
synchronize_data := false,
forward_origins := '{}');
create_subscription
Expand Down
4 changes: 2 additions & 2 deletions expected/init.out
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ALTER EXTENSION pglogical UPDATE;
List of installed extensions
Name | Version | Schema | Description
-----------+---------+-----------+--------------------------------
pglogical | 2.3.0 | pglogical | PostgreSQL Logical Replication
pglogical | 2.3.1 | pglogical | PostgreSQL Logical Replication
(1 row)

SELECT * FROM pglogical.create_node(node_name := 'test_provider', dsn := (SELECT provider_dsn FROM pglogical_regress_variables()) || ' user=super');
Expand Down Expand Up @@ -86,7 +86,7 @@ BEGIN;
SELECT * FROM pglogical.create_subscription(
subscription_name := 'test_subscription',
provider_dsn := (SELECT provider_dsn FROM pglogical_regress_variables()) || ' user=super',
synchronize_structure := 'all',
synchronize_structure := true,
forward_origins := '{}');
create_subscription
---------------------
Expand Down
Loading

0 comments on commit 19d6f4f

Please sign in to comment.