diff --git a/cstore.h b/cstore.h index 489a4839b..c84588627 100644 --- a/cstore.h +++ b/cstore.h @@ -20,6 +20,7 @@ #include "storage/bufpage.h" #include "storage/lockdefs.h" #include "utils/relcache.h" +#include "utils/snapmgr.h" /* Defines for valid option names */ #define OPTION_NAME_COMPRESSION_TYPE "compression" diff --git a/cstore_metadata_tables.c b/cstore_metadata_tables.c index 7c214eed5..565a37b07 100644 --- a/cstore_metadata_tables.c +++ b/cstore_metadata_tables.c @@ -377,7 +377,8 @@ ReadDataFileMetadata(Oid relfilenode, bool missingOk) index = index_open(CStoreStripesIndexRelationId(), AccessShareLock); tupleDescriptor = RelationGetDescr(cstoreStripes); - scanDescriptor = systable_beginscan_ordered(cstoreStripes, index, NULL, 1, scanKey); + scanDescriptor = systable_beginscan_ordered(cstoreStripes, index, NULL, 1, + scanKey); while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor))) { diff --git a/cstore_tableam.c b/cstore_tableam.c index fa3cd8739..4e9d47260 100644 --- a/cstore_tableam.c +++ b/cstore_tableam.c @@ -631,7 +631,7 @@ LogRelationStats(Relation rel, int elevel) TupleDesc tupdesc = RelationGetDescr(rel); uint64 droppedBlocksWithData = 0; - datafileMetadata = ReadDataFileMetadata(relfilenode); + datafileMetadata = ReadDataFileMetadata(relfilenode, false); stripeCount = list_length(datafileMetadata->stripeMetadataList); foreach(stripeMetadataCell, datafileMetadata->stripeMetadataList) @@ -765,15 +765,7 @@ TruncateCStore(Relation rel, int elevel) old_rel_pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM); RelationCloseSmgr(rel); - /* - * Get metadata as viewed in latest snapshot. Reading metadata in transaction - * snapshot is not enough, since stripes could have been created between - * current transaction start and lock acquisition time. Ignoring those - * stripes can destory data. - */ - PushActiveSnapshot(GetLatestSnapshot()); - metadata = ReadDataFileMetadata(rel->rd_node.relNode); - PopActiveSnapshot(); + metadata = ReadDataFileMetadata(rel->rd_node.relNode, false); /* loop over stripes and find max used block */ foreach(stripeMetadataCell, metadata->stripeMetadataList)