mirror of https://github.com/citusdata/citus.git
Lock relations before calling citus_table_size().
This is to make sure they don't get dropped.pull/1751/head
parent
97d544b75c
commit
c18c6625d9
|
@ -154,6 +154,17 @@ DistributedTablesSize(List *distTableOids)
|
|||
Oid relationId = lfirst_oid(distTableOidCell);
|
||||
Datum tableSizeDatum = 0;
|
||||
|
||||
/*
|
||||
* Relations can get dropped after getting the Oid list and before we
|
||||
* reach here. Acquire a lock to make sure the relation is available
|
||||
* while we are getting its size.
|
||||
*/
|
||||
Relation relation = try_relation_open(relationId, AccessShareLock);
|
||||
if (relation == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ignore hash partitioned tables with size greater than 1, since
|
||||
* citus_table_size() doesn't work on them.
|
||||
|
@ -167,6 +178,7 @@ DistributedTablesSize(List *distTableOids)
|
|||
tableSizeDatum = DirectFunctionCall1(citus_table_size,
|
||||
ObjectIdGetDatum(relationId));
|
||||
totalSize += DatumGetInt64(tableSizeDatum);
|
||||
heap_close(relation, AccessShareLock);
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
|
|
Loading…
Reference in New Issue