Don't grab in additional locks cstore code when truncating

pull/4311/head
Hadi Moshayedi 2020-11-09 23:23:50 -08:00 committed by Nils Dijk
parent d065bb495d
commit 691fdb2c64
No known key found for this signature in database
GPG Key ID: CA1177EF9434F241
2 changed files with 13 additions and 2 deletions

View File

@ -718,7 +718,7 @@ FindCStoreTables(List *tableList)
foreach(relationCell, tableList)
{
RangeVar *rangeVar = (RangeVar *) lfirst(relationCell);
Oid relationId = RangeVarGetRelid(rangeVar, AccessShareLock, true);
Oid relationId = RangeVarGetRelid(rangeVar, NoLock, true);
if (IsCStoreFdwTable(relationId) && !DistributedTable(relationId))
{
cstoreTableList = lappend(cstoreTableList, rangeVar);
@ -758,6 +758,17 @@ OpenRelationsForTruncate(List *cstoreTableList)
{
heap_close(relation, AccessExclusiveLock);
}
/*
* Type of cstore tables can change since we checked last time,
* since we didn't hold a lock when checking.
*/
else if (!IsCStoreFdwTable(relationId))
{
ereport(ERROR, (errmsg("relation \"%s\" not columnar anymore",
RelationGetRelationName(relation)),
errhint("try repeating the truncate command")));
}
else
{
relationIdList = lappend_oid(relationIdList, relationId);

View File

@ -58,7 +58,7 @@
* These are the same values from src/backend/access/heap/vacuumlazy.c
*/
#define VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL 50 /* ms */
#define VACUUM_TRUNCATE_LOCK_TIMEOUT 5000 /* ms */
#define VACUUM_TRUNCATE_LOCK_TIMEOUT 4500 /* ms */
typedef struct CStoreScanDescData
{