Skip to content

Commit 89e1be6

Browse files
committed
Merge branch 'CORE-470-test_64_xid' into PGPROEE9_6
2 parents b620f2d + f9b622e commit 89e1be6

File tree

5 files changed

+81
-9
lines changed

5 files changed

+81
-9
lines changed

src/backend/access/transam/xlog.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ int CommitDelay = 0; /* precommit delay in microseconds */
103103
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
104104
int wal_retrieve_retry_interval = 5000;
105105

106+
TransactionId start_xid = 0;
107+
MultiXactId start_mx_id = 0;
108+
MultiXactOffset start_mx_offset = 0;
109+
106110
#ifdef WAL_DEBUG
107111
bool XLOG_DEBUG = false;
108112
#endif
@@ -4832,14 +4836,13 @@ BootStrapXLOG(void)
48324836
checkPoint.ThisTimeLineID = ThisTimeLineID;
48334837
checkPoint.PrevTimeLineID = ThisTimeLineID;
48344838
checkPoint.fullPageWrites = fullPageWrites;
4835-
checkPoint.nextXid = FirstNormalTransactionId + 1;
4839+
checkPoint.nextXid = Max(FirstNormalTransactionId + 1, start_xid);
48364840
checkPoint.nextOid = FirstBootstrapObjectId;
4837-
checkPoint.nextMulti = FirstMultiXactId;
4838-
checkPoint.nextMultiOffset = 0;
4839-
checkPoint.nextMulti++;
4841+
checkPoint.nextMulti = Max(FirstMultiXactId + 1, start_mx_id);
4842+
checkPoint.nextMultiOffset = start_mx_offset;
48404843
checkPoint.oldestXid = checkPoint.nextXid - 1;
48414844
checkPoint.oldestXidDB = TemplateDbOid;
4842-
checkPoint.oldestMulti = FirstMultiXactId;
4845+
checkPoint.oldestMulti = checkPoint.nextMulti - 1;
48434846
checkPoint.oldestMultiDB = TemplateDbOid;
48444847
checkPoint.oldestCommitTsXid = InvalidTransactionId;
48454848
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, HEX_XID_FMT, &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, XID_FMT, &start_mx_offset) != 1)
261+
{
262+
fprintf(stderr, "%s: invalid decimal 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, HEX_XID_FMT, &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: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ static bool sync_only = false;
144144
static bool show_setting = false;
145145
static bool data_checksums = false;
146146
static char *xlog_dir = "";
147+
static TransactionId start_xid = 0;
148+
static MultiXactId start_mx_id = 0;
149+
static MultiXactOffset start_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 " HEX_XID_FMT " %s " HEX_XID_FMT " %s " XID_FMT " %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;
@@ -2683,16 +2689,24 @@ usage(const char *progname)
26832689
printf(_(" --no-locale equivalent to --locale=C\n"));
26842690
printf(_(" --pwfile=FILE read password for the new superuser from file\n"));
26852691
printf(_(" -T, --text-search-config=CFG\n"
2686-
" default text search configuration\n"));
2692+
" default text search configuration\n"));
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 value in hex format for new db instance to test 64-bit xids,\n"
2697+
" default value is 0\n"));
26902698
printf(_("\nLess commonly used options:\n"));
26912699
printf(_(" -d, --debug generate lots of debugging output\n"));
26922700
printf(_(" -k, --data-checksums use data page checksums\n"));
26932701
printf(_(" -L DIRECTORY where to find the input files\n"));
2702+
printf(_(" -m, --multixact-id=START_MX_ID\n"
2703+
" specify start multixact id value in hex format for new db instance\n"
2704+
" to test 64-bit xids, default value is 0\n"));
26942705
printf(_(" -n, --noclean do not clean up after errors\n"));
26952706
printf(_(" -N, --nosync do not wait for changes to be written safely to disk\n"));
2707+
printf(_(" -o, --multixact-offset=START_MX_OFFSET\n"
2708+
" specify start multixact offset value in decimal format for new db instance\n"
2709+
" to test 64-bit xids, default value is 0\n"));
26962710
printf(_(" -s, --show show internal settings\n"));
26972711
printf(_(" -S, --sync-only only sync data directory\n"));
26982712
printf(_("\nOther options:\n"));
@@ -3371,6 +3385,9 @@ main(int argc, char *argv[])
33713385
{"nosync", no_argument, NULL, 'N'},
33723386
{"sync-only", no_argument, NULL, 'S'},
33733387
{"xlogdir", required_argument, NULL, 'X'},
3388+
{"xid", required_argument, NULL, 'x'},
3389+
{"multixact-id", required_argument, NULL, 'm'},
3390+
{"multixact-offset", required_argument, NULL, 'o'},
33743391
{"data-checksums", no_argument, NULL, 'k'},
33753392
{NULL, 0, NULL, 0}
33763393
};
@@ -3412,7 +3429,7 @@ main(int argc, char *argv[])
34123429

34133430
/* process command-line options */
34143431

3415-
while ((c = getopt_long(argc, argv, "dD:E:kL:nNU:WA:sST:X:", long_options, &option_index)) != -1)
3432+
while ((c = getopt_long(argc, argv, "dD:E:kL:m:nNU:WA:o:sST:X:x:", long_options, &option_index)) != -1)
34163433
{
34173434
switch (c)
34183435
{
@@ -3451,13 +3468,27 @@ main(int argc, char *argv[])
34513468
debug = true;
34523469
printf(_("Running in debug mode.\n"));
34533470
break;
3471+
case 'm':
3472+
if (sscanf(optarg, HEX_XID_FMT, &start_mx_id) != 1)
3473+
{
3474+
fprintf(stderr, "%s: invalid hex value of multixact-id\n", progname);
3475+
exit(1);
3476+
}
3477+
break;
34543478
case 'n':
34553479
noclean = true;
34563480
printf(_("Running in noclean mode. Mistakes will not be cleaned up.\n"));
34573481
break;
34583482
case 'N':
34593483
do_sync = false;
34603484
break;
3485+
case 'o':
3486+
if (sscanf(optarg, XID_FMT, &start_mx_offset) != 1)
3487+
{
3488+
fprintf(stderr, "%s: invalid decimal value of multixact-offset\n", progname);
3489+
exit(1);
3490+
}
3491+
break;
34613492
case 'S':
34623493
sync_only = true;
34633494
break;
@@ -3503,6 +3534,13 @@ main(int argc, char *argv[])
35033534
case 'X':
35043535
xlog_dir = pg_strdup(optarg);
35053536
break;
3537+
case 'x':
3538+
if (sscanf(optarg, HEX_XID_FMT, &start_xid) != 1)
3539+
{
3540+
fprintf(stderr, "%s: invalid hex value of xid\n", progname);
3541+
exit(1);
3542+
}
3543+
break;
35063544
default:
35073545
/* getopt_long already emitted a complaint */
35083546
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
extern PGDLLIMPORT int wal_level;
129129

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

src/include/c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ typedef uint64 SubTransactionId;
407407
#define TopSubTransactionId ((SubTransactionId) 1)
408408

409409
#define XID_FMT UINT64_FORMAT
410+
#define HEX_XID_FMT "%" INT64_MODIFIER "x"
410411

411412
/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
412413
typedef TransactionId MultiXactId;

0 commit comments

Comments
 (0)