Skip to content

Commit 8b16a73

Browse files
committed
Clear ptrack_control if ptrack_enable is false.
1 parent c565a18 commit 8b16a73

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/backend/access/heap/ptrack.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,19 @@ SetPtrackClearLSN(bool set_invalid)
271271
{
272272
int fd;
273273
XLogRecPtr ptr;
274-
char path[MAXPGPATH];
275274
if (set_invalid)
276275
ptr = InvalidXLogRecPtr;
277276
else
278277
ptr = GetXLogInsertRecPtr();
279-
snprintf(path, sizeof(path), "%s/global/ptrack_control", DataDir);
280278
//LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
281-
fd = BasicOpenFile(path,
282-
O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
279+
fd = BasicOpenFile("global/ptrack_control",
280+
O_RDWR | O_CREAT | PG_BINARY,
283281
S_IRUSR | S_IWUSR);
284282
if (fd < 0)
285283
ereport(PANIC,
286284
(errcode_for_file_access(),
287285
errmsg("could not create ptrack control file \"%s\": %m",
288-
path)));
286+
"global/ptrack_control")));
289287

290288
errno = 0;
291289
if (write(fd, &ptr, sizeof(XLogRecPtr)) != sizeof(XLogRecPtr))
@@ -470,7 +468,6 @@ pg_ptrack_test(PG_FUNCTION_ARGS)
470468
void
471469
assign_ptrack_enable(bool newval, void *extra)
472470
{
473-
/*elog(WARNING, "assign_ptrack_enable:%s %i", newval ? "true" : "false", IsInitProcessingMode());
474-
if(IsInitProcessingMode() && !newval)
475-
SetPtrackClearLSN(true);*/
471+
if(DataDir != NULL && !IsBootstrapProcessingMode() && !newval)
472+
SetPtrackClearLSN(true);
476473
}

src/backend/utils/init/postinit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "access/sysattr.h"
2525
#include "access/xact.h"
2626
#include "access/xlog.h"
27+
#include "access/ptrack.h"
2728
#include "catalog/catalog.h"
2829
#include "catalog/indexing.h"
2930
#include "catalog/namespace.h"
@@ -552,6 +553,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
552553

553554
elog(DEBUG3, "InitPostgres");
554555

556+
assign_ptrack_enable(ptrack_enable, NULL);
557+
555558
/*
556559
* Add my PGPROC struct to the ProcArray.
557560
*

src/backend/utils/misc/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ static struct config_bool ConfigureNamesBool[] =
988988
},
989989

990990
{
991-
{"ptrack_enable", PGC_POSTMASTER, WAL_SETTINGS,
991+
{"ptrack_enable", PGC_SU_BACKEND, WAL_SETTINGS,
992992
gettext_noop("Enable page tracking."),
993993
NULL
994994
},

0 commit comments

Comments
 (0)