mirror of https://github.com/citusdata/citus.git
Use SnapshotDirty for reading metadata in truncation
parent
55885c81dd
commit
76a71aa61a
1
cstore.h
1
cstore.h
|
@ -20,6 +20,7 @@
|
||||||
#include "storage/bufpage.h"
|
#include "storage/bufpage.h"
|
||||||
#include "storage/lockdefs.h"
|
#include "storage/lockdefs.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
|
#include "utils/snapmgr.h"
|
||||||
|
|
||||||
/* Defines for valid option names */
|
/* Defines for valid option names */
|
||||||
#define OPTION_NAME_COMPRESSION_TYPE "compression"
|
#define OPTION_NAME_COMPRESSION_TYPE "compression"
|
||||||
|
|
|
@ -377,7 +377,8 @@ ReadDataFileMetadata(Oid relfilenode, bool missingOk)
|
||||||
index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
index = index_open(CStoreStripesIndexRelationId(), AccessShareLock);
|
||||||
tupleDescriptor = RelationGetDescr(cstoreStripes);
|
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)))
|
while (HeapTupleIsValid(heapTuple = systable_getnext(scanDescriptor)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -631,7 +631,7 @@ LogRelationStats(Relation rel, int elevel)
|
||||||
TupleDesc tupdesc = RelationGetDescr(rel);
|
TupleDesc tupdesc = RelationGetDescr(rel);
|
||||||
uint64 droppedBlocksWithData = 0;
|
uint64 droppedBlocksWithData = 0;
|
||||||
|
|
||||||
datafileMetadata = ReadDataFileMetadata(relfilenode);
|
datafileMetadata = ReadDataFileMetadata(relfilenode, false);
|
||||||
stripeCount = list_length(datafileMetadata->stripeMetadataList);
|
stripeCount = list_length(datafileMetadata->stripeMetadataList);
|
||||||
|
|
||||||
foreach(stripeMetadataCell, datafileMetadata->stripeMetadataList)
|
foreach(stripeMetadataCell, datafileMetadata->stripeMetadataList)
|
||||||
|
@ -765,15 +765,7 @@ TruncateCStore(Relation rel, int elevel)
|
||||||
old_rel_pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM);
|
old_rel_pages = smgrnblocks(rel->rd_smgr, MAIN_FORKNUM);
|
||||||
RelationCloseSmgr(rel);
|
RelationCloseSmgr(rel);
|
||||||
|
|
||||||
/*
|
metadata = ReadDataFileMetadata(rel->rd_node.relNode, false);
|
||||||
* 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();
|
|
||||||
|
|
||||||
/* loop over stripes and find max used block */
|
/* loop over stripes and find max used block */
|
||||||
foreach(stripeMetadataCell, metadata->stripeMetadataList)
|
foreach(stripeMetadataCell, metadata->stripeMetadataList)
|
||||||
|
|
Loading…
Reference in New Issue