Skip to content

Commit c565a18

Browse files
committed
Experements with assign ptrack_enable.
1 parent 1af025f commit c565a18

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

src/backend/access/heap/ptrack.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool ptrack_enable = false;
4646
static Buffer ptrack_readbuf(RelFileNode rnode, BlockNumber blkno, bool extend);
4747
static void ptrack_extend(SMgrRelation smgr, BlockNumber nvmblocks);
4848
static void ptrack_set(BlockNumber heapBlk, Buffer vmBuf);
49-
void SetPtrackClearLSN(void);
49+
void SetPtrackClearLSN(bool set_invalid);
5050
Datum pg_ptrack_test(PG_FUNCTION_ARGS);
5151

5252
void
@@ -263,23 +263,29 @@ void ptrack_clear(void)
263263
systable_endscan(scan);
264264
heap_close(catalog, AccessShareLock);
265265

266-
SetPtrackClearLSN();
266+
SetPtrackClearLSN(false);
267267
}
268268

269269
void
270-
SetPtrackClearLSN(void)
270+
SetPtrackClearLSN(bool set_invalid)
271271
{
272272
int fd;
273-
XLogRecPtr ptr = GetXLogInsertRecPtr();
273+
XLogRecPtr ptr;
274+
char path[MAXPGPATH];
275+
if (set_invalid)
276+
ptr = InvalidXLogRecPtr;
277+
else
278+
ptr = GetXLogInsertRecPtr();
279+
snprintf(path, sizeof(path), "%s/global/ptrack_control", DataDir);
274280
//LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
275-
fd = BasicOpenFile("global/ptrack_control",
276-
O_RDWR | O_CREAT | PG_BINARY,
281+
fd = BasicOpenFile(path,
282+
O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
277283
S_IRUSR | S_IWUSR);
278284
if (fd < 0)
279285
ereport(PANIC,
280286
(errcode_for_file_access(),
281287
errmsg("could not create ptrack control file \"%s\": %m",
282-
"global/ptrack_control")));
288+
path)));
283289

284290
errno = 0;
285291
if (write(fd, &ptr, sizeof(XLogRecPtr)) != sizeof(XLogRecPtr))
@@ -460,3 +466,11 @@ pg_ptrack_test(PG_FUNCTION_ARGS)
460466
result_array = construct_array(result_elems, 2, 23, 4, true, 'i');
461467
PG_RETURN_ARRAYTYPE_P(result_array);
462468
}
469+
470+
void
471+
assign_ptrack_enable(bool newval, void *extra)
472+
{
473+
/*elog(WARNING, "assign_ptrack_enable:%s %i", newval ? "true" : "false", IsInitProcessingMode());
474+
if(IsInitProcessingMode() && !newval)
475+
SetPtrackClearLSN(true);*/
476+
}

src/backend/utils/misc/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ static struct config_bool ConfigureNamesBool[] =
994994
},
995995
&ptrack_enable,
996996
false,
997-
NULL, NULL, NULL
997+
NULL, &assign_ptrack_enable, NULL
998998
},
999999

10001000
{

src/include/access/ptrack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ extern bool ptrack_enable;
1313

1414
extern void ptrack_save(void);
1515

16-
extern void
17-
ptrack_add_block(BlockNumber block_number, RelFileNode rel);
16+
extern void ptrack_add_block(BlockNumber block_number, RelFileNode rel);
1817

1918
extern void ptrack_clear(void);
19+
extern void assign_ptrack_enable(bool newval, void *extra);
2020

2121
#endif /* VISIBILITYMAP_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy