提交 58b88aa4 编写于 作者: A Adam Berlin 提交者: Adam Berlin

squash! Skip attempts to create target gp tablespace.

handle force overwrite scenario for --target-gp-dbid
上级 a313569f
......@@ -14,7 +14,7 @@ CREATE
(exited with code 0)
-- Given a segment with a database that has a tablespace
!\retcode mkdir /tmp/some_isolation2_pg_basebackup_tablespace;
!\retcode mkdir -p /tmp/some_isolation2_pg_basebackup_tablespace;
-- start_ignore
-- end_ignore
......@@ -32,16 +32,29 @@ create database some_database_with_tablespace tablespace some_isolation2_pg_base
CREATE
-- When we create a full backup
select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p';
select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p';
pg_basebackup
---------------
(1 row)
-- Then we should have a backup of the source segment files in the newly created target tablespace
-- expect: 1
select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/');
count_of_items_in_directory
-----------------------------
1
(1 row)
-- When we create a full backup using force overwrite
select pg_basebackup(address, 200, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p';
pg_basebackup
---------------
(1 row)
-- Then we should have a backup of the source segment files in the newly created target tablespace
select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/');
count_of_items_in_directory
-----------------------------
1
(1 row)
......@@ -6,16 +6,21 @@ create or replace language plpythonu;
-- port: port of the gpdb segment to back up
-- slotname: desired slot name to create and associate with backup
-- datadir: destination data directory of the backup
-- forceoverwrite: overwrite the destination directory if it exists already
--
--
-- usage: `select pg_basebackup('somehost', 12345, 'some_slot_name', '/some/destination/data/directory')`
--
create or replace function pg_basebackup(host text, dbid int, port int, slotname text, datadir text) returns text as $$
create or replace function pg_basebackup(host text, dbid int, port int, slotname text, datadir text, force_overwrite boolean) returns text as $$
import subprocess
cmd = 'pg_basebackup -h %s -p %d --xlog-method stream -R -D %s --target-gp-dbid %d' % (host, port, datadir, dbid)
if slotname is not None:
cmd += ' --slot %s' % (slotname)
if force_overwrite:
cmd += ' --force-overwrite'
try:
results = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '')
except subprocess.CalledProcessError as e:
......
......@@ -5,7 +5,7 @@ include: helpers/gp_management_utils_helpers.sql;
!\retcode rm -rf /tmp/some_isolation2_pg_basebackup_tablespace;
-- Given a segment with a database that has a tablespace
!\retcode mkdir /tmp/some_isolation2_pg_basebackup_tablespace;
!\retcode mkdir -p /tmp/some_isolation2_pg_basebackup_tablespace;
drop tablespace if exists some_isolation2_pg_basebackup_tablespace;
create tablespace some_isolation2_pg_basebackup_tablespace location '/tmp/some_isolation2_pg_basebackup_tablespace';
......@@ -15,8 +15,13 @@ drop database if exists some_database_with_tablespace;
create database some_database_with_tablespace tablespace some_isolation2_pg_basebackup_tablespace;
-- When we create a full backup
select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup') from gp_segment_configuration where content = 0 and role = 'p';
select pg_basebackup(address, 100, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', false) from gp_segment_configuration where content = 0 and role = 'p';
-- Then we should have a backup of the source segment files in the newly created target tablespace
-- expect: 1
select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db100/');
-- When we create a full backup using force overwrite
select pg_basebackup(address, 200, port, 'some_replication_slot', '/tmp/some_isolation2_pg_basebackup', true) from gp_segment_configuration where content = 0 and role = 'p';
-- Then we should have a backup of the source segment files in the newly created target tablespace
select count_of_items_in_directory('/tmp/some_isolation2_pg_basebackup_tablespace/GPDB_*db200/');
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册