Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe2d8b5

Browse files
committed
Add GUC enabling global snapshots.
1 parent6aa72a0 commitbe2d8b5

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

‎src/backend/access/transam/global_snapshot.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ typedef struct
8484
#defineDTM_TRACE(x)
8585
/* #define DTM_TRACE(x) fprintf x */
8686

87+
/* GUC enabling global snapshots */
88+
booltrack_global_snapshots;
89+
8790
// static shmem_startup_hook_type prev_shmem_startup_hook;
8891
staticHTAB*xid2status;
8992
staticHTAB*gtid2xid;
@@ -1019,8 +1022,12 @@ Datum
10191022
pg_global_snaphot_create(PG_FUNCTION_ARGS)
10201023
{
10211024
GlobalTransactionIdgtid=text_to_cstring(PG_GETARG_TEXT_PP(0));
1022-
cid_tcid=DtmLocalExtend(&dtm_tx,gtid);
1025+
cid_tcid;
1026+
1027+
if (!track_global_snapshots)
1028+
elog(ERROR,"Global snapshots are disabled");
10231029

1030+
cid=DtmLocalExtend(&dtm_tx,gtid);
10241031
DTM_TRACE((stderr,"Backend %d extends transaction %u(%s) to global with cid=%lu\n",getpid(),dtm_tx.xid,gtid,cid));
10251032
PG_RETURN_INT64(cid);
10261033
}
@@ -1031,6 +1038,9 @@ pg_global_snaphot_join(PG_FUNCTION_ARGS)
10311038
cid_tcid=PG_GETARG_INT64(0);
10321039
GlobalTransactionIdgtid=text_to_cstring(PG_GETARG_TEXT_PP(1));
10331040

1041+
if (!track_global_snapshots)
1042+
elog(ERROR,"Global snapshots are disabled");
1043+
10341044
DTM_TRACE((stderr,"Backend %d joins transaction %u(%s) with cid=%lu\n",getpid(),dtm_tx.xid,gtid,cid));
10351045
cid=DtmLocalAccess(&dtm_tx,gtid,cid);
10361046
PG_RETURN_INT64(cid);
@@ -1041,6 +1051,9 @@ pg_global_snaphot_begin_prepare(PG_FUNCTION_ARGS)
10411051
{
10421052
GlobalTransactionIdgtid=text_to_cstring(PG_GETARG_TEXT_PP(0));
10431053

1054+
if (!track_global_snapshots)
1055+
elog(ERROR,"Global snapshots are disabled");
1056+
10441057
DtmLocalBeginPrepare(gtid);
10451058
DTM_TRACE((stderr,"Backend %d begins prepare of transaction %s\n",getpid(),gtid));
10461059
PG_RETURN_VOID();
@@ -1052,6 +1065,10 @@ pg_global_snaphot_prepare(PG_FUNCTION_ARGS)
10521065
GlobalTransactionIdgtid=text_to_cstring(PG_GETARG_TEXT_PP(0));
10531066
cid_tcid=PG_GETARG_INT64(1);
10541067

1068+
if (!track_global_snapshots)
1069+
elog(ERROR,"Global snapshots are disabled");
1070+
1071+
10551072
cid=DtmLocalPrepare(gtid,cid);
10561073
DTM_TRACE((stderr,"Backend %d prepares transaction %s with cid=%lu\n",getpid(),gtid,cid));
10571074
PG_RETURN_INT64(cid);
@@ -1063,6 +1080,9 @@ pg_global_snaphot_end_prepare(PG_FUNCTION_ARGS)
10631080
GlobalTransactionIdgtid=text_to_cstring(PG_GETARG_TEXT_PP(0));
10641081
cid_tcid=PG_GETARG_INT64(1);
10651082

1083+
if (!track_global_snapshots)
1084+
elog(ERROR,"Global snapshots are disabled");
1085+
10661086
DTM_TRACE((stderr,"Backend %d ends prepare of transactions %s with cid=%lu\n",getpid(),gtid,cid));
10671087
DtmLocalEndPrepare(gtid,cid);
10681088
PG_RETURN_VOID();

‎src/backend/storage/ipc/ipci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"access/clog.h"
1818
#include"access/commit_ts.h"
1919
#include"access/heapam.h"
20+
#include"access/global_snapshot.h"
2021
#include"access/multixact.h"
2122
#include"access/nbtree.h"
2223
#include"access/subtrans.h"
@@ -272,7 +273,9 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
272273
SyncScanShmemInit();
273274
AsyncShmemInit();
274275
BackendRandomShmemInit();
275-
DtmInitialize();
276+
277+
if (track_global_snapshots)
278+
DtmInitialize();
276279

277280
#ifdefEXEC_BACKEND
278281

‎src/backend/utils/misc/guc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include"access/commit_ts.h"
3030
#include"access/gin.h"
31+
#include"access/global_snapshot.h"
3132
#include"access/rmgr.h"
3233
#include"access/transam.h"
3334
#include"access/twophase.h"
@@ -1666,6 +1667,16 @@ static struct config_bool ConfigureNamesBool[] =
16661667
NULL,NULL,NULL
16671668
},
16681669

1670+
{
1671+
{"track_global_snapshots",PGC_POSTMASTER,CUSTOM_OPTIONS,
1672+
gettext_noop("Track global snapshots, allowing to use global_snapshot API"),
1673+
NULL
1674+
},
1675+
&track_global_snapshots,
1676+
false,
1677+
NULL,NULL,NULL
1678+
},
1679+
16691680
/* End-of-list marker */
16701681
{
16711682
{NULL,0,0,NULL,NULL},NULL, false,NULL,NULL,NULL

‎src/include/access/global_snapshot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
typedefintnodeid_t;
77
typedefuint64cid_t;
88

9+
externbooltrack_global_snapshots;
10+
911
typedefstruct
1012
{
1113
TransactionIdxid;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp