Skip to content

Instantly share code, notes, and snippets.

@tsohr
Last active October 6, 2018 15:49
Show Gist options
  • Select an option

  • Save tsohr/ec7903809e0a5c73d03d4c8308bc522d to your computer and use it in GitHub Desktop.

Select an option

Save tsohr/ec7903809e0a5c73d03d4c8308bc522d to your computer and use it in GitHub Desktop.
Bucardo session replication role hack
#must read
# https://www.compose.com/articles/using-bucardo-5-3-to-migrate-a-live-postgresql-database/
# https://www.sqlgossip.com/configure-bucardo-replication-centos/
# https://www.srijn.net/2015/09/postgresql-replication-using-bucardo/
5324 ## Can we do this the easy way? Thanks to Jan for srr!
5325 my $dbname = $db->{name};
5326 if ($dbh->{pg_server_version} >= 80300) {
5327 $self->glog("Setting session_replication_role to replica for database $dbname", LOG_VERBOSE);
5328 $dbh->do(q{DO LANGUAGE plpgsql $$DECLARE somevar VARCHAR; BEGIN SELECT p.proname INTO somevar FROM pg_catalog.pg_proc p WHERE p.proname = 'rds_session_replication_role' LIMIT 1; IF NOT FOUND THEN SET session_replication_rol e = 'replica'; ELSE PERFORM rds_session_replication_role('replica'); END IF; END$$;});
5329 #$dbh->do(q{SET session_replication_role = 'replica'});
5330
5331 $db->{triggers_enabled} = 0;
5332 return undef;
5333 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment