Skip to content

Commit

Permalink
add isolation2
Browse files Browse the repository at this point in the history
  • Loading branch information
wenchaozhang-123 committed Apr 2, 2024
1 parent 386e3c8 commit bd9f56b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/backend/commands/copyfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,6 @@ CopyFromDirectoryTable(CopyFromState cstate)
StringInfoData buf;
ExprContext *econtext;
int bytesRead;
//int bytesWrite;
char hexMd5Sum[256];
char buffer[DIR_FILE_BUFF_SIZE];
int64 processed = 0;
Expand Down Expand Up @@ -858,7 +857,6 @@ CopyFromDirectoryTable(CopyFromState cstate)
/* Assemble directory table file location. */
relaFileName = trimFilePath(glob_copystmt->dirfilename, '/');
dirTable = GetDirectoryTable(RelationGetRelid(cstate->rel));
//TODO DFS compatible implement
orgiFileName = formatLocalFileName(&cstate->rel->rd_node, relaFileName);

/*
Expand Down
5 changes: 3 additions & 2 deletions src/backend/commands/dirtablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ remove_file_segment(PG_FUNCTION_ARGS)

dirTable = GetDirectoryTable(relId);
relation = table_open(relId, AccessExclusiveLock);

SIMPLE_FAULT_INJECTOR("remove_file_inject");

indexOids = RelationGetIndexList(relation);
Assert(list_length(indexOids) == 1);

Expand Down Expand Up @@ -423,8 +426,6 @@ remove_file(PG_FUNCTION_ARGS)

relation = table_open(relId, AccessExclusiveLock);

SIMPLE_FAULT_INJECTOR("remove_file_inject");

if (Gp_role != GP_ROLE_DISPATCH)
ereport(ERROR,
(errcode(ERRCODE_GP_COMMAND_ERROR),
Expand Down
70 changes: 41 additions & 29 deletions src/test/isolation2/input/local_directory_table_mixed.source
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-- Mixed test for local directory table
-- setup for temp tablespace
! rm -rf '@testtablespace@';
! mkdir -p '@testtablespace@';
CREATE TABLESPACE directory_tblspc LOCATION '@testtablespace@';

-- Test create directory table and create directory table
Expand Down Expand Up @@ -26,14 +29,14 @@ CREATE TABLESPACE directory_tblspc LOCATION '@testtablespace@';
1: BEGIN;
2: BEGIN;
1: COPY BINARY dir_table2 FROM '@abs_srcdir@/data/nation.csv' 'nation5';
2: SELECT relative_path, size, md5, tag FROM dir_table2;
2: SELECT relative_path, size, tag, md5 FROM dir_table2 ORDER BY 1;
1: COMMIT;
2: COMMIT;

1: BEGIN;
2: BEGIN;
1: COPY BINARY dir_table2 FROM '@abs_srcdir@/data/nation.csv' 'nation6';
2: SELECT relative_path, size, md5, tag FROM directory_table('dir_table2');
2: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table2') ORDER BY 1;
1: COMMIT;
2: COMMIT;

Expand All @@ -49,61 +52,70 @@ CREATE TABLESPACE directory_tblspc LOCATION '@testtablespace@';
-- Test select and select
1: BEGIN;
2: BEGIN;
1: SELECT relative_path, size, md5, tag FROM dir_table1;
2: SELECT relative_path, size, md5, tag, content FROM directory_table('dir_table2');
1: SELECT relative_path, size, md5, tag, content FROM directory_table('dir_table2');
2: SELECT relative_path, size, md5, tag FROM dir_table1;
1: SELECT relative_path, size, tag, md5 FROM dir_table1 ORDER BY 1;
2: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table2') ORDER BY 1;
1: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table2') ORDER BY 1;
2: SELECT relative_path, size, tag, md5 FROM dir_table1 ORDER BY 1;
2: COMMIT;
1: COMMIT;

-- Test select and remove_file()
1: BEGIN;
2: BEGIN;
1: SELECT relative_path, size, md5, tag FROM dir_table1;
2: SELECT remove_file('dir_table2', 'nation4');
2: COMMIT;
1: SELECT gp_inject_fault('directory_table_inject', 'sleep', '', '', '', 1, 1, 2, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table1') ORDER BY 1;
2&: SELECT remove_file('dir_table1', 'nation7');
3: SELECT gp_wait_until_triggered_fault('directory_table_inject', 3, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: COMMIT;

1: BEGIN;
2: BEGIN;
1: SELECT remove_file('dir_table1', 'nation4');
2: SELECT relative_path, size, md5, tag FROM dir_table2;
2<:
2: COMMIT;
1: COMMIT;

-- Test remove and remove
SELECT gp_inject_fault('directory_table_inject', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;

1: BEGIN;
2: BEGIN;
1: SELECT remove_file('dir_table2', 'nation2');
2&: SELECT remove_file('dir_table2', 'nation2');
1: SELECT gp_inject_fault('remove_file_inject', 'sleep', '', '', '', 1, 1, 2, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: SELECT remove_file('dir_table1', 'nation5');
2&: SELECT relative_path, size, tag, md5 FROM dir_table1 ORDER BY 1;
3: SELECT gp_wait_until_triggered_fault('remove_file_inject', 3, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: COMMIT;
2<:
2: COMMIT;

-- Test create directory table and drop directory table
SELECT gp_inject_fault('directory_table_inject', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;

1: BEGIN;
2: BEGIN;
1: CREATE DIRECTORY TABLE dir_table3 TABLESPACE directory_tblspc;
2: DROP DIRECTORY TABLE dir_table2;
2: CREATE DIRECTORY TABLE dir_table2 TABLESPACE directory_tblspc;
1: SELECT gp_inject_fault('remove_file_inject', 'sleep', '', '', '', 1, 1, 2, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: SELECT remove_file('dir_table2', 'nation6');
2&: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table2') ORDER BY 1;
3: SELECT gp_wait_until_triggered_fault('remove_file_inject', 3, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: COMMIT;
2<:
2: COMMIT;

-- Test drop directory table and copy from/select
SELECT gp_inject_fault('directory_table_inject', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;

1: BEGIN;
2: BEGIN;
1: COPY BINARY dir_table3 FROM '@abs_srcdir@/data/nation.csv' 'nation1';
2&: DROP DIRECTORY TABLE dir_table3;
1: SELECT gp_inject_fault('directory_table_inject', 'sleep', '', '', '', 1, 1, 2, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: SELECT relative_path, size, tag, md5, content FROM directory_table('dir_table2') ORDER BY 1;
2&: SELECT remove_file('dir_table2', 'nation5');
3: SELECT gp_wait_until_triggered_fault('directory_table_inject', 3, dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;
1: COMMIT;
2<:
2: COMMIT;

SELECT gp_inject_fault('directory_table_inject', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' and content >= 0;

-- Test create directory table and drop directory table
1: BEGIN;
2: BEGIN;
1: SELECT relative_path, size, md5, tag, content FROM directory_table('dir_table1');
2&: DROP DIRECTORY TABLE dir_table2;
1: CREATE DIRECTORY TABLE dir_table3 TABLESPACE directory_tblspc;
2: DROP DIRECTORY TABLE dir_table2;
2: CREATE DIRECTORY TABLE dir_table2 TABLESPACE directory_tblspc;
1: COMMIT;
2<:
2: COMMIT;

DROP TABLESPACE directory_tblspc;
DROP TABLESPACE directory_tblspc;
! rm -rf '@testtablespace@';

0 comments on commit bd9f56b

Please sign in to comment.