This is an automated email from the ASF dual-hosted git repository. maxyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 74fb1386c865c5ad22fc0424084dc4056c28b62f Author: Soumyadeep Chakraborty <[email protected]> AuthorDate: Wed Mar 9 18:04:09 2022 -0800 Helper for sizing a distributed snapshot's xip[] --- src/backend/cdb/cdbdistributedsnapshot.c | 12 +++++++++--- src/include/cdb/cdbdistributedsnapshot.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/cdb/cdbdistributedsnapshot.c b/src/backend/cdb/cdbdistributedsnapshot.c index eec1355843..f53413f65f 100644 --- a/src/backend/cdb/cdbdistributedsnapshot.c +++ b/src/backend/cdb/cdbdistributedsnapshot.c @@ -23,6 +23,12 @@ #include "utils/snapmgr.h" #include "storage/procarray.h" +int +GetMaxSnapshotDistributedXidCount() +{ + return GetMaxSnapshotXidCount(); +} + /* * DistributedSnapshotWithLocalMapping_CommittedTest * Is the given XID still-in-progress according to the @@ -210,7 +216,7 @@ DistributedSnapshot_Reset(DistributedSnapshot *distributedSnapshot) if (distributedSnapshot->inProgressXidArray == NULL) { distributedSnapshot->inProgressXidArray = - (DistributedTransactionId*) malloc(GetMaxSnapshotXidCount() * sizeof(DistributedTransactionId)); + (DistributedTransactionId*) malloc(GetMaxSnapshotDistributedXidCount() * sizeof(DistributedTransactionId)); if (distributedSnapshot->inProgressXidArray == NULL) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), @@ -252,14 +258,14 @@ DistributedSnapshot_Copy(DistributedSnapshot *target, if (target->inProgressXidArray == NULL) { target->inProgressXidArray = - (DistributedTransactionId*) malloc(GetMaxSnapshotXidCount() * sizeof(DistributedTransactionId)); + (DistributedTransactionId*) malloc(GetMaxSnapshotDistributedXidCount() * sizeof(DistributedTransactionId)); if (target->inProgressXidArray == NULL) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); } - Assert(source->count <= GetMaxSnapshotXidCount()); + Assert(source->count <= GetMaxSnapshotDistributedXidCount()); memcpy(target->inProgressXidArray, source->inProgressXidArray, source->count * sizeof(DistributedTransactionId)); diff --git a/src/include/cdb/cdbdistributedsnapshot.h b/src/include/cdb/cdbdistributedsnapshot.h index 02a923d356..7187e39fb9 100644 --- a/src/include/cdb/cdbdistributedsnapshot.h +++ b/src/include/cdb/cdbdistributedsnapshot.h @@ -66,6 +66,8 @@ typedef enum DISTRIBUTEDSNAPSHOT_COMMITTED_IGNORE } DistributedSnapshotCommitted; +extern int GetMaxSnapshotDistributedXidCount(void); + extern DistributedSnapshotCommitted DistributedSnapshotWithLocalMapping_CommittedTest( DistributedSnapshotWithLocalMapping *dslm, TransactionId localXid, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
