Skip to content

Commit

Permalink
Update fault injector to better handle tableName argument.
Browse files Browse the repository at this point in the history
Calls to FaultInjector_InjectFaultIfSet that provide tableName as an
argument currently break early if the tableName does not match the
hash entry (set by gp_inject_fault) for the fault. This is problematic
because the fault must be set with a specific table name to be triggered at all.

This commit modifies the behavior to only check for matching tableName
if the hash entry has a tableName set. This allows for more targeted
testing.

Example:

Setting fault without a tableName will trigger for any table:

```
postgres=# SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'skip', '', '', '', 1, 100, 0, dbid)
    FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
 gp_inject_fault
-----------------
 Success:
(1 row)

postgres=# copy alter_attach_t1 to '/dev/null';
COPY 100000
postgres=# copy alter_attach_t2 to '/dev/null';
COPY 100000
postgres=# SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'status', dbid)
    FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
                                                                                                                   gp_inject_fault
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Success: fault name:'AppendOnlyStorageRead_ReadNextBlock_success' fault type:'skip' ddl statement:'' database name:'' table name:'' start occurrence:'1' end occurrence:'100' extra arg:'0' fault injection state:'completed'  num times hit:'100' +
```

Setting fault with a given tableName will trigger only for that table.

```
postgres=# SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'skip', '', '', 'alter_attach_t1', 1, 100, 0, dbid)
    FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
 gp_inject_fault
-----------------
 Success:
(1 row)

postgres=# copy alter_attach_t1 to '/dev/null';
COPY 100000
postgres=# copy alter_attach_t2 to '/dev/null';
COPY 100000
postgres=# SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'status', dbid)
    FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
                                                                                                                          gp_inject_fault
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Success: fault name:'AppendOnlyStorageRead_ReadNextBlock_success' fault type:'skip' ddl statement:'' database name:'' table name:'alter_attach_t1' start occurrence:'1' end occurrence:'100' extra arg:'0' fault injection state:'triggered'  num times hit:'51' +
```

Authored-by: Brent Doil <[email protected]>
  • Loading branch information
bmdoil authored and reshke committed Sep 16, 2024
1 parent 43c2189 commit 964a6f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/utils/misc/faultinjector.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ FaultInjector_InjectFaultIfSet_out_of_line(
/* fault injection is not set for the specified database name */
break;

if (strcmp(entryShared->tableName, tableNameLocal) != 0)
if (strlen(entryShared->tableName) > 0 && strcmp(entryShared->tableName, tableNameLocal) != 0)
/* fault injection is not set for the specified table name */
break;

Expand Down

0 comments on commit 964a6f9

Please sign in to comment.