From: Craig Ringer Date: Fri, 19 Dec 2014 08:47:13 +0000 (+0800) Subject: bdr: Use bdr.do_not_replicate to suppress replication of pg_restore X-Git-Tag: bdr-plugin/0.8.0~23 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=b07636e8fa01bcb1d84304c72cd69c3e863e7ebf;p=2ndquadrant_bdr.git bdr: Use bdr.do_not_replicate to suppress replication of pg_restore Changes from pg_restore would have previously been replicated through the slot from the new node back to the root node during init, because we didn't apply them with any replicaiton origin ID. Use the bdr.do_not_replicate GUC to set DoNotReplicateRepNodeID as the origin, so these changes get suppressed from replication. --- diff --git a/bdr_init_replica.c b/bdr_init_replica.c index d84a7acbb8..e9fbd0fcbc 100644 --- a/bdr_init_replica.c +++ b/bdr_init_replica.c @@ -519,8 +519,8 @@ bdr_exec_init_replica(BdrConnectionConfig *cfg, char *snapshot) &bdr_init_replica_script_path[0]) < 0) { elog(ERROR, "bdr: failed to find " BDR_INIT_REPLICA_CMD - " relative to binary %s or wrong version (expected %s)", - my_exec_path, PG_VERSION); + " relative to binary %s or wrong version. Expected (PostgreSQL %s, BDR %s)", + my_exec_path, PG_VERSION, BDR_VERSION); } if (find_other_exec(my_exec_path, BDR_DUMP_CMD, @@ -552,6 +552,17 @@ bdr_exec_init_replica(BdrConnectionConfig *cfg, char *snapshot) "%s fallback_application_name='"BDR_LOCALID_FORMAT": %s: init_replica restore'", cfg->replica_local_dsn, BDR_LOCALID_FORMAT_ARGS, cfg->name); + /* + * Suppress replication of changes applied via pg_restore back to + * the local node. + * + * XXX DYNCONF: This should PQconninfoParse, modify the options keyword or + * add it, and reconstruct the string using the functions from pg_dumpall + * (also to be used for init_copy). This is a hack. + */ + appendStringInfoString(&local_dsn, + " options='-c bdr.do_not_replicate=on -c bdr.permit_unsafe_ddl_commands=on -c bdr.skip_ddl_replication=on -c bdr.skip_ddl_locking=on'"); + tmpdir = palloc(strlen(bdr_temp_dump_directory)+32); sprintf(tmpdir, "%s/postgres-bdr-%s.%d", bdr_temp_dump_directory, snapshot, getpid()); diff --git a/scripts/bdr_initial_load.in b/scripts/bdr_initial_load.in index ca1e6cdde1..50eb1c20fc 100644 --- a/scripts/bdr_initial_load.in +++ b/scripts/bdr_initial_load.in @@ -92,7 +92,7 @@ if ! "$PGDUMP" -j $JOBS $SNAP -F d -f $TMPDIR "$SOURCE"; then fi errlog "Restoring dump to local DB \"$TARGET\" with $JOBS concurrent workers from \"$TMPDIR\"" -if ! PGOPTIONS="-c bdr.permit_unsafe_ddl_commands=true -c bdr.skip_ddl_replication=true" "$PGRESTORE" --exit-on-error --single-transaction -j $JOBS -F d -d "$TARGET" $TMPDIR; then +if ! "$PGRESTORE" --exit-on-error --single-transaction -j $JOBS -F d -d "$TARGET" $TMPDIR; then errlog "pg_restore to "$TARGET" failed, aborting" exit 2 fi