Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bdr_quickstart.sh: Use shallow clone, to make it faster #199

Open
wants to merge 2 commits into
base: bdr-plugin/next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ DATA = \
extsql/bdr--0.10.0.4--0.10.0.5.sql \
extsql/bdr--0.10.0.5--0.10.0.6.sql \
extsql/bdr--0.10.0.6--0.10.0.7.sql \
extsql/bdr--0.10.0.7--0.10.0.8.sql
extsql/bdr--0.10.0.7--0.10.0.8.sql \
extsql/bdr--0.10.0.8--0.10.0.9.sql

DATA_built = \
extsql/bdr--0.8.0.1.sql \
Expand All @@ -68,7 +69,8 @@ DATA_built = \
extsql/bdr--0.10.0.5.sql \
extsql/bdr--0.10.0.6.sql \
extsql/bdr--0.10.0.7.sql \
extsql/bdr--0.10.0.8.sql
extsql/bdr--0.10.0.8.sql \
extsql/bdr--0.10.0.9.sql

DOCS = bdr.conf.sample README.bdr
SCRIPTS = scripts/bdr_initial_load bdr_init_copy bdr_resetxlog bdr_dump
Expand Down Expand Up @@ -242,6 +244,10 @@ extsql/bdr--0.10.0.8.sql: extsql/bdr--0.10.0.7.sql extsql/bdr--0.10.0.7--0.10.0.
mkdir -p extsql
cat $^ > $@

extsql/bdr--0.10.0.9.sql: extsql/bdr--0.10.0.8.sql extsql/bdr--0.10.0.8--0.10.0.9.sql
mkdir -p extsql
cat $^ > $@

bdr_resetxlog: pg_resetxlog.o
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(libpq_pgport) $(LIBS) -o $@$(X)

Expand Down
2 changes: 1 addition & 1 deletion bdr.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bdr extension
comment = 'Bi-directional replication for PostgreSQL'
default_version = '0.10.0.8'
default_version = '0.10.0.9'
module_pathname = '$libdir/bdr'
relocatable = false
requires = btree_gist
Expand Down
14 changes: 14 additions & 0 deletions expected/init_bdr.out
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ SELECT node_status, node_local_dsn, node_init_from_dsn FROM bdr.bdr_nodes ORDER
r | dbname=regression | dbname=postgres
(2 rows)

SELECT 1 FROM bdr.pg_replication_slots WHERE restart_lsn <= confirmed_flush_lsn;
?column?
----------
1
1
(2 rows)

\c regression
SELECT conn_dsn, conn_replication_sets FROM bdr.bdr_connections ORDER BY conn_dsn;
conn_dsn | conn_replication_sets
Expand All @@ -81,6 +88,13 @@ SELECT node_status, node_local_dsn, node_init_from_dsn FROM bdr.bdr_nodes ORDER
r | dbname=regression | dbname=postgres
(2 rows)

SELECT 1 FROM bdr.pg_replication_slots WHERE restart_lsn <= confirmed_flush_lsn;
?column?
----------
1
1
(2 rows)

SET bdr.permit_ddl_locking = true;
SELECT bdr.bdr_replicate_ddl_command($DDL$
CREATE OR REPLACE FUNCTION public.bdr_regress_variables(
Expand Down
7 changes: 5 additions & 2 deletions expected/upgrade.out
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ CREATE EXTENSION bdr VERSION '0.10.0.7';
DROP EXTENSION bdr;
CREATE EXTENSION bdr VERSION '0.10.0.8';
DROP EXTENSION bdr;
CREATE EXTENSION bdr VERSION '0.10.0.9';
DROP EXTENSION bdr;
-- evolve version one by one from the oldest to the newest one
CREATE EXTENSION bdr VERSION '0.8.0';
ALTER EXTENSION bdr UPDATE TO '0.8.0.1';
Expand Down Expand Up @@ -119,14 +121,15 @@ ORDER BY t.tgname;
(2 rows)

ALTER EXTENSION bdr UPDATE TO '0.10.0.8';
ALTER EXTENSION bdr UPDATE TO '0.10.0.9';
-- Should never have to do anything: You missed adding the new version above.
ALTER EXTENSION bdr UPDATE;
NOTICE: version "0.10.0.8" of extension "bdr" is already installed
NOTICE: version "0.10.0.9" of extension "bdr" is already installed
\dx bdr
List of installed extensions
Name | Version | Schema | Description
------+----------+------------+-------------------------------------------
bdr | 0.10.0.8 | pg_catalog | Bi-directional replication for PostgreSQL
bdr | 0.10.0.9 | pg_catalog | Bi-directional replication for PostgreSQL
(1 row)

\c postgres
Expand Down
38 changes: 38 additions & 0 deletions extsql/bdr--0.10.0.8--0.10.0.9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SET LOCAL search_path = bdr;
SET bdr.permit_unsafe_ddl_commands = true;
SET bdr.skip_ddl_replication = true;

-- Define an alias of pg_catalog.pg_get_replication_slots to expose the extra
-- active_pid and confirmed_flush_lsn columns from 9.5 and 9.6 that have been
-- backported to 94bdr. The new columns MUST be last.
--
CREATE OR REPLACE FUNCTION
bdr.pg_get_replication_slots(OUT slot_name name, OUT plugin name, OUT slot_type text, OUT datoid oid, OUT active boolean, OUT xmin xid, OUT catalog_xmin xid, OUT restart_lsn pg_lsn, OUT active_pid integer, OUT confirmed_flush_lsn pg_lsn)
RETURNS SETOF record
LANGUAGE internal
STABLE ROWS 10
AS $function$pg_get_replication_slots$function$;


-- And a replacement pg_replication_slots view, so if you set your search_path
-- appropriately it'll "just work". The view fixes the column ordering to be
-- the same as 9.6.
CREATE VIEW bdr.pg_replication_slots AS
SELECT
L.slot_name,
L.plugin,
L.slot_type,
L.datoid,
D.datname AS database,
L.active,
L.active_pid,
L.xmin,
L.catalog_xmin,
L.restart_lsn,
L.confirmed_flush_lsn
FROM bdr.pg_get_replication_slots() AS L
LEFT JOIN pg_catalog.pg_database D ON (L.datoid = D.oid);

RESET bdr.permit_unsafe_ddl_commands;
RESET bdr.skip_ddl_replication;
RESET search_path;
2 changes: 1 addition & 1 deletion scripts/bdr_quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ clone_or_update() {
echo "Cloning $GITREF sources from git://git.postgresql.org/git/2ndquadrant_bdr.git"
echo "This may take some time depending on the speed of your connection."

if ! git clone -b "$GITREF" git://git.postgresql.org/git/2ndquadrant_bdr.git $SRCDIR; then
if ! git clone -b "$GITREF" --depth=1 git://git.postgresql.org/git/2ndquadrant_bdr.git $SRCDIR; then
echo "The git clone of the BDR repository failed. Network issues?"
echo "Try running the script again. If it fails again, look at the git "
echo "output to see what went wrong."
Expand Down
4 changes: 4 additions & 0 deletions sql/init_bdr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ SELECT count(*) FROM pg_stat_replication;
SELECT conn_dsn, conn_replication_sets FROM bdr.bdr_connections ORDER BY conn_dsn;
SELECT node_status, node_local_dsn, node_init_from_dsn FROM bdr.bdr_nodes ORDER BY node_local_dsn;

SELECT 1 FROM bdr.pg_replication_slots WHERE restart_lsn <= confirmed_flush_lsn;

\c regression
SELECT conn_dsn, conn_replication_sets FROM bdr.bdr_connections ORDER BY conn_dsn;
SELECT node_status, node_local_dsn, node_init_from_dsn FROM bdr.bdr_nodes ORDER BY node_local_dsn;

SELECT 1 FROM bdr.pg_replication_slots WHERE restart_lsn <= confirmed_flush_lsn;

SET bdr.permit_ddl_locking = true;

SELECT bdr.bdr_replicate_ddl_command($DDL$
Expand Down
5 changes: 5 additions & 0 deletions sql/upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ DROP EXTENSION bdr;
CREATE EXTENSION bdr VERSION '0.10.0.8';
DROP EXTENSION bdr;

CREATE EXTENSION bdr VERSION '0.10.0.9';
DROP EXTENSION bdr;

-- evolve version one by one from the oldest to the newest one
CREATE EXTENSION bdr VERSION '0.8.0';
ALTER EXTENSION bdr UPDATE TO '0.8.0.1';
Expand Down Expand Up @@ -142,6 +145,8 @@ ORDER BY t.tgname;

ALTER EXTENSION bdr UPDATE TO '0.10.0.8';

ALTER EXTENSION bdr UPDATE TO '0.10.0.9';

-- Should never have to do anything: You missed adding the new version above.
ALTER EXTENSION bdr UPDATE;

Expand Down