mirror of https://github.com/citusdata/citus.git
Fix null relation name issue in CheckConflictingRelationAccesses
parent
d66f011f71
commit
001089783c
|
@ -713,14 +713,37 @@ CheckConflictingRelationAccesses(Oid relationId, ShardPlacementAccessType access
|
||||||
char *conflictingAccessTypeText =
|
char *conflictingAccessTypeText =
|
||||||
PlacementAccessTypeToText(conflictingAccessType);
|
PlacementAccessTypeToText(conflictingAccessType);
|
||||||
|
|
||||||
ereport(ERROR, (errmsg("cannot execute %s on reference relation \"%s\" because "
|
/*
|
||||||
"there was a parallel %s access to distributed relation "
|
* Relation could already be dropped if the accessType is DDL and the
|
||||||
"\"%s\" in the same transaction",
|
* command that we were executing were a DROP command. In that case,
|
||||||
accessTypeText, relationName, conflictingAccessTypeText,
|
* as this function is executed via DROP trigger, standard_ProcessUtility
|
||||||
conflictingRelationName),
|
* had already dropped the table from PostgreSQL's perspective. Hence, it
|
||||||
errhint("Try re-running the transaction with "
|
* returns NULL pointer for the name of the relation.
|
||||||
"\"SET LOCAL citus.multi_shard_modify_mode TO "
|
*/
|
||||||
"\'sequential\';\"")));
|
if (relationName == NULL)
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg("cannot execute %s on reference relation because "
|
||||||
|
"there was a parallel %s access to distributed relation "
|
||||||
|
"\"%s\" in the same transaction",
|
||||||
|
accessTypeText, conflictingAccessTypeText,
|
||||||
|
conflictingRelationName),
|
||||||
|
errhint("Try re-running the transaction with "
|
||||||
|
"\"SET LOCAL citus.multi_shard_modify_mode TO "
|
||||||
|
"\'sequential\';\"")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg(
|
||||||
|
"cannot execute %s on reference relation \"%s\" because "
|
||||||
|
"there was a parallel %s access to distributed relation "
|
||||||
|
"\"%s\" in the same transaction",
|
||||||
|
accessTypeText, relationName,
|
||||||
|
conflictingAccessTypeText,
|
||||||
|
conflictingRelationName),
|
||||||
|
errhint("Try re-running the transaction with "
|
||||||
|
"\"SET LOCAL citus.multi_shard_modify_mode TO "
|
||||||
|
"\'sequential\';\"")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (cacheEntry->referencingRelationsViaForeignKey != NIL &&
|
else if (cacheEntry->referencingRelationsViaForeignKey != NIL &&
|
||||||
accessType > PLACEMENT_ACCESS_SELECT)
|
accessType > PLACEMENT_ACCESS_SELECT)
|
||||||
|
|
|
@ -857,6 +857,35 @@ BEGIN;
|
||||||
NOTICE: truncate cascades to table "reference_table"
|
NOTICE: truncate cascades to table "reference_table"
|
||||||
NOTICE: truncate cascades to table "on_update_fkey_table"
|
NOTICE: truncate cascades to table "on_update_fkey_table"
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
-- case 4.7: SELECT to a dist table is followed by a DROP
|
||||||
|
-- DROP following SELECT is important as we error out after
|
||||||
|
-- the standart process utility hook drops the table.
|
||||||
|
-- That could cause SIGSEGV before the patch.
|
||||||
|
-- Below block should "successfully" error out
|
||||||
|
BEGIN;
|
||||||
|
SELECT count(*) FROM on_update_fkey_table;
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1001
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE reference_table CASCADE;
|
||||||
|
NOTICE: drop cascades to constraint fkey on table on_update_fkey_table
|
||||||
|
ERROR: cannot execute DDL on reference relation because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction
|
||||||
|
ROLLBACK;
|
||||||
|
-- case 4.8: Router SELECT to a dist table is followed by a TRUNCATE
|
||||||
|
-- No errors expected from below block as SELECT there is a router
|
||||||
|
-- query
|
||||||
|
BEGIN;
|
||||||
|
SELECT count(*) FROM on_update_fkey_table WHERE id = 9;
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE reference_table CASCADE;
|
||||||
|
NOTICE: drop cascades to constraint fkey on table on_update_fkey_table
|
||||||
|
ROLLBACK;
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\set VERBOSITY default
|
\set VERBOSITY default
|
||||||
-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT
|
-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT
|
||||||
|
|
|
@ -489,6 +489,24 @@ BEGIN;
|
||||||
TRUNCATE transitive_reference_table CASCADE;
|
TRUNCATE transitive_reference_table CASCADE;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- case 4.7: SELECT to a dist table is followed by a DROP
|
||||||
|
-- DROP following SELECT is important as we error out after
|
||||||
|
-- the standart process utility hook drops the table.
|
||||||
|
-- That could cause SIGSEGV before the patch.
|
||||||
|
-- Below block should "successfully" error out
|
||||||
|
BEGIN;
|
||||||
|
SELECT count(*) FROM on_update_fkey_table;
|
||||||
|
DROP TABLE reference_table CASCADE;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
|
-- case 4.8: Router SELECT to a dist table is followed by a TRUNCATE
|
||||||
|
-- No errors expected from below block as SELECT there is a router
|
||||||
|
-- query
|
||||||
|
BEGIN;
|
||||||
|
SELECT count(*) FROM on_update_fkey_table WHERE id = 9;
|
||||||
|
DROP TABLE reference_table CASCADE;
|
||||||
|
ROLLBACK;
|
||||||
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\set VERBOSITY default
|
\set VERBOSITY default
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue