| -- start_ignore |
| \! gpstop -u; |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Starting gpstop with args: -u |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Gathering information and validating the environment... |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Obtaining Cloudberry Master catalog information |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Obtaining Segment details from master... |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Cloudberry Version: 'postgres (Apache Cloudberry) 7.0.0-alpha.0+dev.487.gc712d6d8b0 build dev' |
| 20190709:16:49:48:083167 gpstop:Weinan-Pivotal-Mac:wwang-[INFO]:-Signalling all postmaster processes to reload |
| create language plpython3u; |
| -- end_ignore |
| --list all database oid relevant directories in all node(master, segments, mirrors, etc.) |
| CREATE OR REPLACE FUNCTION db_dirs(dboid oid) RETURNS setof text |
| STRICT STABLE LANGUAGE plpython3u |
| as $$ |
| import os |
| bash_cmd = "find " + os.getcwd() + "/../../ " + "-name %d -type d" |
| p = os.popen(bash_cmd % dboid) |
| return p.readlines() |
| $$; |
| -- |
| --CASE 0: createdb do well |
| -- |
| create database dowell; |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| select count(*)=0 as result from |
| (select db_dirs(oid) from pg_database where datname = 'dowell') as foo; |
| result |
| -------- |
| f |
| (1 row) |
| |
| \! psql -d dowell -Xc "create table test1(a int, b text)" |
| NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table. |
| HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. |
| CREATE TABLE |
| \! psql -d dowell -Xc "insert into test1 values (1, '111'), (2, '222'), (3, '333')" |
| INSERT 0 3 |
| \! psql -d dowell -Xc "select * from test1" |
| a | b |
| ---+----- |
| 2 | 222 |
| 3 | 333 |
| 1 | 111 |
| (3 rows) |
| |
| drop database dowell; |
| -- |
| --CASE 1: error in segment after db file physically created |
| -- |
| --reset status |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| (8 rows) |
| |
| -- inject fault on content0 primary to error out after copying |
| -- template db directory |
| select gp_inject_fault('create_db_after_file_copy', 'error', dbid) |
| from gp_segment_configuration where content=0 and role='p'; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| -- should fail |
| create database db_with_leftover_files; |
| ERROR: fault triggered, fault name:'create_db_after_file_copy' fault type:'error' (seg0 10.34.49.130:25432 pid=83183) |
| -- Wait until replay_lsn = flush_lsn. |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| -- since this is a failed case, db oid is invisible, however we need it to search |
| -- our tablespace to check if has db files left over. |
| set gp_select_invisible=on; |
| select db_dirs(oid) from pg_database where datname = 'db_with_leftover_files'; |
| db_dirs |
| --------- |
| (0 rows) |
| |
| -- cleanup |
| set gp_select_invisible=off; |
| -- |
| --CASE 2: error after XLOG_DBASE_CREATE on master |
| -- |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| (8 rows) |
| |
| select gp_inject_fault('after_xlog_create_database', 'error', dbid) |
| from gp_segment_configuration where content=-1 and role='p'; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| -- should fail |
| create database db2; |
| ERROR: fault triggered, fault name:'after_xlog_create_database' fault type:'error' |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| -- since this is a failed case, db oid is invisible, however we need it to search |
| -- our tablespace to check if has db files left over. |
| set gp_select_invisible=on; |
| select db_dirs(oid) from pg_database where datname = 'db2'; |
| db_dirs |
| --------- |
| (0 rows) |
| |
| set gp_select_invisible=off; |
| -- |
| --CASE 3: error after XLOG_DBASE_CREATE on segment |
| -- |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| (8 rows) |
| |
| select gp_inject_fault('after_xlog_create_database', 'error', dbid) |
| from gp_segment_configuration where content=0 and role='p'; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| -- should fail |
| create database db3; |
| ERROR: fault triggered, fault name:'after_xlog_create_database' fault type:'error' (seg0 10.34.49.130:25432 pid=83183) |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| -- since this is a failed case, db oid is invisible, however we need it to search |
| -- our tablespace to check if has db files left over. |
| set gp_select_invisible=on; |
| select db_dirs(oid) from pg_database where datname = 'db3'; |
| db_dirs |
| --------- |
| (0 rows) |
| |
| set gp_select_invisible=off; |
| -- |
| --CASE 4: panic after XLOG_XACT_PREPARE on segment |
| -- |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| (8 rows) |
| |
| select gp_inject_fault_infinite('fts_probe', 'skip', dbid) |
| from gp_segment_configuration where content=-1 and role='p'; |
| gp_inject_fault_infinite |
| -------------------------- |
| Success: |
| (1 row) |
| |
| select gp_inject_fault('end_prepare_two_phase', 'panic', dbid) |
| from gp_segment_configuration where content=0 and role='p'; |
| WARNING: consider disabling FTS probes while injecting a panic. (seg0 127.0.1.1:7002 pid=5973) |
| HINT: Inject an infinite 'skip' into the 'fts_probe' fault to disable FTS probing. |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| -- should fail |
| create database db4; |
| ERROR: fault triggered, fault name:'end_prepare_two_phase' fault type:'panic' (seg0 10.34.49.130:25432 pid=83183) |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| -- since this is a failed case, db oid is invisible, however we need it to search |
| -- our tablespace to check if has db files left over. |
| set gp_select_invisible=on; |
| select db_dirs(oid) from pg_database where datname = 'db4'; |
| db_dirs |
| --------- |
| (0 rows) |
| |
| set gp_select_invisible=off; |
| -- start_ignore |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| Success: |
| (8 rows) |
| |
| select force_mirrors_to_catch_up(); |
| force_mirrors_to_catch_up |
| --------------------------- |
| |
| (1 row) |
| |
| -- end_ignore |