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

Commitbe99416

Browse files
author
Maksim Milyutin
committed
Add parameters to initdb and postgres to specify start xid, multixact id and multixact offset
1 parent0565d47 commitbe99416

File tree

5 files changed

+89
-7
lines changed

5 files changed

+89
-7
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,20 @@ BootStrapMultiXact(void)
17141714
}
17151715

17161716
LWLockRelease(MultiXactMemberControlLock);
1717+
1718+
/*
1719+
* If we're starting not from zero offset, initilize dummy multixact to
1720+
* evade too long loop in PerformMembersTruncation().
1721+
*/
1722+
if (MultiXactState->nextOffset>0&&MultiXactState->nextMXact>0)
1723+
{
1724+
RecordNewMultiXact(FirstMultiXactId,
1725+
MultiXactState->nextOffset,
1726+
0,NULL);
1727+
RecordNewMultiXact(MultiXactState->nextMXact-1,
1728+
MultiXactState->nextOffset,
1729+
0,NULL);
1730+
}
17171731
}
17181732

17191733
/*

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ intCommitDelay = 0;/* precommit delay in microseconds */
103103
intCommitSiblings=5;/* # concurrent xacts needed to sleep */
104104
intwal_retrieve_retry_interval=5000;
105105

106+
TransactionIdstart_xid=0;
107+
MultiXactIdstart_mx_id=0;
108+
MultiXactOffsetstart_mx_offset=0;
109+
106110
#ifdefWAL_DEBUG
107111
boolXLOG_DEBUG= false;
108112
#endif
@@ -4806,14 +4810,15 @@ BootStrapXLOG(void)
48064810
checkPoint.ThisTimeLineID=ThisTimeLineID;
48074811
checkPoint.PrevTimeLineID=ThisTimeLineID;
48084812
checkPoint.fullPageWrites=fullPageWrites;
4809-
checkPoint.nextXid=FirstNormalTransactionId+1;
4813+
checkPoint.nextXid=FirstNormalTransactionId+1+start_xid;
48104814
checkPoint.nextOid=FirstBootstrapObjectId;
48114815
checkPoint.nextMulti=FirstMultiXactId;
4812-
checkPoint.nextMultiOffset=0;
4813-
checkPoint.nextMulti++;
4816+
checkPoint.nextMulti= (!start_mx_id) ?FirstMultiXactId+1
4817+
:FirstMultiXactId+start_mx_id;
4818+
checkPoint.nextMultiOffset=start_mx_offset;
48144819
checkPoint.oldestXid=checkPoint.nextXid-1;
48154820
checkPoint.oldestXidDB=TemplateDbOid;
4816-
checkPoint.oldestMulti=FirstMultiXactId;
4821+
checkPoint.oldestMulti=checkPoint.nextMulti-1;
48174822
checkPoint.oldestMultiDB=TemplateDbOid;
48184823
checkPoint.oldestCommitTsXid=InvalidTransactionId;
48194824
checkPoint.newestCommitTsXid=InvalidTransactionId;

‎src/backend/bootstrap/bootstrap.c‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ AuxiliaryProcessMain(int argc, char *argv[])
219219
/* If no -x argument, we are a CheckerProcess */
220220
MyAuxProcType=CheckerProcess;
221221

222-
while ((flag=getopt(argc,argv,"B:c:d:D:Fkr:x:-:"))!=-1)
222+
start_xid=start_mx_id=start_mx_offset=0;
223+
while ((flag=getopt(argc,argv,"B:c:d:D:Fkm:o:r:X:x:-:"))!=-1)
223224
{
224225
switch (flag)
225226
{
@@ -248,9 +249,30 @@ AuxiliaryProcessMain(int argc, char *argv[])
248249
case'k':
249250
bootstrap_data_checksum_version=PG_DATA_CHECKSUM_VERSION;
250251
break;
252+
case'm':
253+
if (sscanf(optarg,"%lx",&start_mx_id)!=1)
254+
{
255+
fprintf(stderr,"%s: invalid hex value of multixact-id\n",progname);
256+
exit(1);
257+
}
258+
break;
259+
case'o':
260+
if (sscanf(optarg,"%lx",&start_mx_offset)!=1)
261+
{
262+
fprintf(stderr,"%s: invalid hex value of multixact-offset\n",progname);
263+
exit(1);
264+
}
265+
break;
251266
case'r':
252267
strlcpy(OutputFileName,optarg,MAXPGPATH);
253268
break;
269+
case'X':
270+
if (sscanf(optarg,"%lx",&start_xid)!=1)
271+
{
272+
fprintf(stderr,"%s: invalid hex value of xid\n",progname);
273+
exit(1);
274+
}
275+
break;
254276
case'x':
255277
MyAuxProcType=atoi(optarg);
256278
break;

‎src/bin/initdb/initdb.c‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ static bool sync_only = false;
144144
staticboolshow_setting= false;
145145
staticbooldata_checksums= false;
146146
staticchar*xlog_dir="";
147+
staticTransactionIdstart_xid=0;
148+
staticMultiXactIdstart_mx_id=0;
149+
staticMultiXactOffsetstart_mx_offset=0;
147150

148151

149152
/* internal vars */
@@ -1535,9 +1538,12 @@ bootstrap_template1(void)
15351538
unsetenv("PGCLIENTENCODING");
15361539

15371540
snprintf(cmd,sizeof(cmd),
1538-
"\"%s\" --boot -x1 %s %s %s",
1541+
"\"%s\" --boot -x1 %s %s %lx %s %lx %s %lx %s %s",
15391542
backend_exec,
15401543
data_checksums ?"-k" :"",
1544+
"-X",start_xid,
1545+
"-m",start_mx_id,
1546+
"-o",start_mx_offset,
15411547
boot_options,talkargs);
15421548

15431549
PG_CMD_OPEN;
@@ -2687,12 +2693,15 @@ usage(const char *progname)
26872693
printf(_(" -U, --username=NAME database superuser name\n"));
26882694
printf(_(" -W, --pwprompt prompt for a password for the new superuser\n"));
26892695
printf(_(" -X, --xlogdir=XLOGDIR location for the transaction log directory\n"));
2696+
printf(_(" -x, --xid=START_XID specify start xid in hex format for new instance to test 64-bit xids, default value is 0\n"));
26902697
printf(_("\nLess commonly used options:\n"));
26912698
printf(_(" -d, --debug generate lots of debugging output\n"));
26922699
printf(_(" -k, --data-checksums use data page checksums\n"));
26932700
printf(_(" -L DIRECTORY where to find the input files\n"));
2701+
printf(_(" -m, --multixact-id=MX_ID specify multixact id in hex format for new instance to test 64-bit xids, default value is 0\n"));
26942702
printf(_(" -n, --noclean do not clean up after errors\n"));
26952703
printf(_(" -N, --nosync do not wait for changes to be written safely to disk\n"));
2704+
printf(_(" -o, --multixact-offset=MX_OFFSET specify multixact offset in hex format for new instance to test 64-bit xids, default value is 0\n"));
26962705
printf(_(" -s, --show show internal settings\n"));
26972706
printf(_(" -S, --sync-only only sync data directory\n"));
26982707
printf(_("\nOther options:\n"));
@@ -3371,6 +3380,9 @@ main(int argc, char *argv[])
33713380
{"nosync",no_argument,NULL,'N'},
33723381
{"sync-only",no_argument,NULL,'S'},
33733382
{"xlogdir",required_argument,NULL,'X'},
3383+
{"xid",required_argument,NULL,'x'},
3384+
{"multixact-id",required_argument,NULL,'m'},
3385+
{"multixact-offset",required_argument,NULL,'o'},
33743386
{"data-checksums",no_argument,NULL,'k'},
33753387
{NULL,0,NULL,0}
33763388
};
@@ -3412,7 +3424,7 @@ main(int argc, char *argv[])
34123424

34133425
/* process command-line options */
34143426

3415-
while ((c=getopt_long(argc,argv,"dD:E:kL:nNU:WA:sST:X:",long_options,&option_index))!=-1)
3427+
while ((c=getopt_long(argc,argv,"dD:E:kL:m:nNU:WA:o:sST:X:x:",long_options,&option_index))!=-1)
34163428
{
34173429
switch (c)
34183430
{
@@ -3451,13 +3463,27 @@ main(int argc, char *argv[])
34513463
debug= true;
34523464
printf(_("Running in debug mode.\n"));
34533465
break;
3466+
case'm':
3467+
if (sscanf(optarg,"%lx",&start_mx_id)!=1)
3468+
{
3469+
fprintf(stderr,"%s: invalid hex value of multixact-id\n",progname);
3470+
exit(1);
3471+
}
3472+
break;
34543473
case'n':
34553474
noclean= true;
34563475
printf(_("Running in noclean mode. Mistakes will not be cleaned up.\n"));
34573476
break;
34583477
case'N':
34593478
do_sync= false;
34603479
break;
3480+
case'o':
3481+
if (sscanf(optarg,"%lx",&start_mx_offset)!=1)
3482+
{
3483+
fprintf(stderr,"%s: invalid hex value of multixact-offset\n",progname);
3484+
exit(1);
3485+
}
3486+
break;
34613487
case'S':
34623488
sync_only= true;
34633489
break;
@@ -3503,6 +3529,13 @@ main(int argc, char *argv[])
35033529
case'X':
35043530
xlog_dir=pg_strdup(optarg);
35053531
break;
3532+
case'x':
3533+
if (sscanf(optarg,"%lx",&start_xid)!=1)
3534+
{
3535+
fprintf(stderr,"%s: invalid hex value of xid\n",progname);
3536+
exit(1);
3537+
}
3538+
break;
35063539
default:
35073540
/* getopt_long already emitted a complaint */
35083541
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),

‎src/include/access/xlog.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ typedef enum WalLevel
127127

128128
externPGDLLIMPORTintwal_level;
129129

130+
/*
131+
* these parameters specifies starting xid, multixact id and multixact offset
132+
* for testing 64 bit xids
133+
*/
134+
externTransactionIdstart_xid;
135+
externMultiXactIdstart_mx_id;
136+
externMultiXactOffsetstart_mx_offset;
137+
130138
/* Is WAL archiving enabled (always or only while server is running normally)? */
131139
#defineXLogArchivingActive() \
132140
(AssertMacro(XLogArchiveMode == ARCHIVE_MODE_OFF || wal_level >= WAL_LEVEL_REPLICA), XLogArchiveMode > ARCHIVE_MODE_OFF)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp