mirror of https://github.com/citusdata/citus.git
Keep read lock until we are done with table relation.
parent
c893454bb8
commit
7d04b40b2d
|
@ -1131,7 +1131,7 @@ DropIdentitiesOnTable(Oid relationId)
|
||||||
{
|
{
|
||||||
Relation relation = relation_open(relationId, AccessShareLock);
|
Relation relation = relation_open(relationId, AccessShareLock);
|
||||||
TupleDesc tupleDescriptor = RelationGetDescr(relation);
|
TupleDesc tupleDescriptor = RelationGetDescr(relation);
|
||||||
relation_close(relation, NoLock);
|
List *dropCommandList = NIL;
|
||||||
|
|
||||||
for (int attributeIndex = 0; attributeIndex < tupleDescriptor->natts;
|
for (int attributeIndex = 0; attributeIndex < tupleDescriptor->natts;
|
||||||
attributeIndex++)
|
attributeIndex++)
|
||||||
|
@ -1151,15 +1151,24 @@ DropIdentitiesOnTable(Oid relationId)
|
||||||
qualifiedTableName,
|
qualifiedTableName,
|
||||||
columnName);
|
columnName);
|
||||||
|
|
||||||
|
dropCommandList = lappend(dropCommandList, dropCommand->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
relation_close(relation, NoLock);
|
||||||
|
|
||||||
|
char *dropCommand = NULL;
|
||||||
|
foreach_ptr(dropCommand, dropCommandList)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* We need to disable/enable ddl propagation for this command, to prevent
|
* We need to disable/enable ddl propagation for this command, to prevent
|
||||||
* sending unnecessary ALTER COLUMN commands for partitions, to MX workers.
|
* sending unnecessary ALTER COLUMN commands for partitions, to MX workers.
|
||||||
*/
|
*/
|
||||||
ExecuteAndLogUtilityCommandList(list_make3(DISABLE_DDL_PROPAGATION,
|
ExecuteAndLogUtilityCommandList(list_make3(DISABLE_DDL_PROPAGATION,
|
||||||
dropCommand->data,
|
dropCommand,
|
||||||
ENABLE_DDL_PROPAGATION));
|
ENABLE_DDL_PROPAGATION));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1896,7 +1896,6 @@ IdentitySequenceDependencyCommandList(Oid targetRelationId)
|
||||||
|
|
||||||
Relation relation = relation_open(targetRelationId, AccessShareLock);
|
Relation relation = relation_open(targetRelationId, AccessShareLock);
|
||||||
TupleDesc tupleDescriptor = RelationGetDescr(relation);
|
TupleDesc tupleDescriptor = RelationGetDescr(relation);
|
||||||
relation_close(relation, NoLock);
|
|
||||||
|
|
||||||
bool tableHasIdentityColumn = false;
|
bool tableHasIdentityColumn = false;
|
||||||
for (int attributeIndex = 0; attributeIndex < tupleDescriptor->natts;
|
for (int attributeIndex = 0; attributeIndex < tupleDescriptor->natts;
|
||||||
|
@ -1911,6 +1910,8 @@ IdentitySequenceDependencyCommandList(Oid targetRelationId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relation_close(relation, NoLock);
|
||||||
|
|
||||||
if (tableHasIdentityColumn)
|
if (tableHasIdentityColumn)
|
||||||
{
|
{
|
||||||
StringInfo stringInfo = makeStringInfo();
|
StringInfo stringInfo = makeStringInfo();
|
||||||
|
|
|
@ -151,7 +151,6 @@ worker_modify_identity_columns(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
Relation tableRelation = relation_open(tableRelationId, AccessShareLock);
|
Relation tableRelation = relation_open(tableRelationId, AccessShareLock);
|
||||||
TupleDesc tableTupleDesc = RelationGetDescr(tableRelation);
|
TupleDesc tableTupleDesc = RelationGetDescr(tableRelation);
|
||||||
relation_close(tableRelation, NoLock);
|
|
||||||
|
|
||||||
bool missingSequenceOk = false;
|
bool missingSequenceOk = false;
|
||||||
|
|
||||||
|
@ -177,6 +176,8 @@ worker_modify_identity_columns(PG_FUNCTION_ARGS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relation_close(tableRelation, NoLock);
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue