Skip to content

Commit 6951c58

Browse files
committed
[PGPRO-6817] update for rel 15 beta.
Tags: ptrack
1 parent 5714dd1 commit 6951c58

File tree

1 file changed

+261
-0
lines changed

1 file changed

+261
-0
lines changed

Diff for: patches/REL_15_STABLE-ptrack-core.diff

+261
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c
2+
index cc16c4b331f..69b1af16cf5 100644
3+
--- a/src/backend/backup/basebackup.c
4+
+++ b/src/backend/backup/basebackup.c
5+
@@ -197,6 +197,13 @@ static const struct exclude_list_item excludeFiles[] =
6+
{"postmaster.pid", false},
7+
{"postmaster.opts", false},
8+
9+
+ /*
10+
+ * Skip all transient ptrack files, but do copy ptrack.map, since it may
11+
+ * be successfully used immediately after backup. TODO: check, test?
12+
+ */
13+
+ {"ptrack.map.mmap", false},
14+
+ {"ptrack.map.tmp", false},
15+
+
16+
/* end of list */
17+
{NULL, false}
18+
};
19+
@@ -212,6 +219,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
20+
{"pg_filenode.map", false},
21+
{"pg_internal.init", true},
22+
{"PG_VERSION", false},
23+
+
24+
+ {"ptrack.map.mmap", false},
25+
+ {"ptrack.map", false},
26+
+ {"ptrack.map.tmp", false},
27+
+
28+
#ifdef EXEC_BACKEND
29+
{"config_exec_params", true},
30+
#endif
31+
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
32+
index 658fd95ba95..eee38eba176 100644
33+
--- a/src/backend/storage/file/copydir.c
34+
+++ b/src/backend/storage/file/copydir.c
35+
@@ -27,6 +27,8 @@
36+
#include "storage/copydir.h"
37+
#include "storage/fd.h"
38+
39+
+copydir_hook_type copydir_hook = NULL;
40+
+
41+
/*
42+
* copydir: copy a directory
43+
*
44+
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
45+
}
46+
FreeDir(xldir);
47+
48+
+ if (copydir_hook)
49+
+ copydir_hook(todir);
50+
+
51+
/*
52+
* Be paranoid here and fsync all files to ensure the copy is really done.
53+
* But if fsync is disabled, we're done.
54+
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
55+
index a0fc60b32a3..7f091951c0d 100644
56+
--- a/src/backend/storage/smgr/md.c
57+
+++ b/src/backend/storage/smgr/md.c
58+
@@ -87,6 +87,8 @@ typedef struct _MdfdVec
59+
60+
static MemoryContext MdCxt; /* context for all MdfdVec objects */
61+
62+
+mdextend_hook_type mdextend_hook = NULL;
63+
+mdwrite_hook_type mdwrite_hook = NULL;
64+
65+
/* Populate a file tag describing an md.c segment file. */
66+
#define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \
67+
@@ -484,6 +486,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
68+
register_dirty_segment(reln, forknum, v);
69+
70+
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
71+
+
72+
+ if (mdextend_hook)
73+
+ mdextend_hook(reln->smgr_rnode, forknum, blocknum);
74+
}
75+
76+
/*
77+
@@ -773,6 +778,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
78+
79+
if (!skipFsync && !SmgrIsTemp(reln))
80+
register_dirty_segment(reln, forknum, v);
81+
+
82+
+ if (mdwrite_hook)
83+
+ mdwrite_hook(reln->smgr_rnode, forknum, blocknum);
84+
}
85+
86+
/*
87+
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
88+
index e1fb6310038..76d75680b31 100644
89+
--- a/src/backend/storage/sync/sync.c
90+
+++ b/src/backend/storage/sync/sync.c
91+
@@ -81,6 +81,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
92+
static CycleCtr sync_cycle_ctr = 0;
93+
static CycleCtr checkpoint_cycle_ctr = 0;
94+
95+
+ProcessSyncRequests_hook_type ProcessSyncRequests_hook = NULL;
96+
+
97+
/* Intervals for calling AbsorbSyncRequests */
98+
#define FSYNCS_PER_ABSORB 10
99+
#define UNLINKS_PER_ABSORB 10
100+
@@ -477,6 +479,9 @@ ProcessSyncRequests(void)
101+
CheckpointStats.ckpt_longest_sync = longest;
102+
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
103+
104+
+ if (ProcessSyncRequests_hook)
105+
+ ProcessSyncRequests_hook();
106+
+
107+
/* Flag successful completion of ProcessSyncRequests */
108+
sync_in_progress = false;
109+
}
110+
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
111+
index 21dfe1b6ee5..266ac1ef40a 100644
112+
--- a/src/bin/pg_checksums/pg_checksums.c
113+
+++ b/src/bin/pg_checksums/pg_checksums.c
114+
@@ -118,6 +118,11 @@ static const struct exclude_list_item skip[] = {
115+
{"pg_filenode.map", false},
116+
{"pg_internal.init", true},
117+
{"PG_VERSION", false},
118+
+
119+
+ {"ptrack.map.mmap", false},
120+
+ {"ptrack.map", false},
121+
+ {"ptrack.map.tmp", false},
122+
+
123+
#ifdef EXEC_BACKEND
124+
{"config_exec_params", true},
125+
#endif
126+
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
127+
index d4772a29650..3318f64359d 100644
128+
--- a/src/bin/pg_resetwal/pg_resetwal.c
129+
+++ b/src/bin/pg_resetwal/pg_resetwal.c
130+
@@ -85,6 +85,7 @@ static void RewriteControlFile(void);
131+
static void FindEndOfXLOG(void);
132+
static void KillExistingXLOG(void);
133+
static void KillExistingArchiveStatus(void);
134+
+static void KillExistingPtrack(void);
135+
static void WriteEmptyXLOG(void);
136+
static void usage(void);
137+
138+
@@ -488,6 +489,7 @@ main(int argc, char *argv[])
139+
RewriteControlFile();
140+
KillExistingXLOG();
141+
KillExistingArchiveStatus();
142+
+ KillExistingPtrack();
143+
WriteEmptyXLOG();
144+
145+
printf(_("Write-ahead log reset\n"));
146+
@@ -1036,6 +1038,41 @@ KillExistingArchiveStatus(void)
147+
pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR);
148+
}
149+
150+
+/*
151+
+ * Remove existing ptrack files
152+
+ */
153+
+static void
154+
+KillExistingPtrack(void)
155+
+{
156+
+#define PTRACKDIR "global"
157+
+
158+
+ DIR *xldir;
159+
+ struct dirent *xlde;
160+
+ char path[MAXPGPATH + sizeof(PTRACKDIR)];
161+
+
162+
+ xldir = opendir(PTRACKDIR);
163+
+ if (xldir == NULL)
164+
+ pg_fatal("could not open directory \"%s\": %m", PTRACKDIR);
165+
+
166+
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
167+
+ {
168+
+ if (strcmp(xlde->d_name, "ptrack.map.mmap") == 0 ||
169+
+ strcmp(xlde->d_name, "ptrack.map") == 0 ||
170+
+ strcmp(xlde->d_name, "ptrack.map.tmp") == 0)
171+
+ {
172+
+ snprintf(path, sizeof(path), "%s/%s", PTRACKDIR, xlde->d_name);
173+
+ if (unlink(path) < 0)
174+
+ pg_fatal("could not delete file \"%s\": %m", path);
175+
+ }
176+
+ }
177+
+
178+
+ if (errno)
179+
+ pg_fatal("could not read directory \"%s\": %m", PTRACKDIR);
180+
+
181+
+ if (closedir(xldir))
182+
+ pg_fatal("could not close directory \"%s\": %m", PTRACKDIR);
183+
+}
184+
+
185+
186+
/*
187+
* Write an empty XLOG file, containing only the checkpoint record
188+
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
189+
index 62529310415..b496f54fb06 100644
190+
--- a/src/bin/pg_rewind/filemap.c
191+
+++ b/src/bin/pg_rewind/filemap.c
192+
@@ -157,6 +157,10 @@ static const struct exclude_list_item excludeFiles[] =
193+
{"postmaster.pid", false},
194+
{"postmaster.opts", false},
195+
196+
+ {"ptrack.map.mmap", false},
197+
+ {"ptrack.map", false},
198+
+ {"ptrack.map.tmp", false},
199+
+
200+
/* end of list */
201+
{NULL, false}
202+
};
203+
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
204+
index d7668651ba8..33994a27f5f 100644
205+
--- a/src/include/port/pg_crc32c.h
206+
+++ b/src/include/port/pg_crc32c.h
207+
@@ -69,7 +69,7 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
208+
#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
209+
210+
extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
211+
-extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
212+
+extern PGDLLIMPORT pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
213+
214+
#ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
215+
extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
216+
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
217+
index 50a26edeb06..af1602f5154 100644
218+
--- a/src/include/storage/copydir.h
219+
+++ b/src/include/storage/copydir.h
220+
@@ -13,6 +13,9 @@
221+
#ifndef COPYDIR_H
222+
#define COPYDIR_H
223+
224+
+typedef void (*copydir_hook_type) (const char *path);
225+
+extern PGDLLIMPORT copydir_hook_type copydir_hook;
226+
+
227+
extern void copydir(char *fromdir, char *todir, bool recurse);
228+
extern void copy_file(char *fromfile, char *tofile);
229+
230+
diff --git a/src/include/storage/md.h b/src/include/storage/md.h
231+
index ffffa40db71..3ff98e0bf01 100644
232+
--- a/src/include/storage/md.h
233+
+++ b/src/include/storage/md.h
234+
@@ -19,6 +19,13 @@
235+
#include "storage/smgr.h"
236+
#include "storage/sync.h"
237+
238+
+typedef void (*mdextend_hook_type) (RelFileNodeBackend smgr_rnode,
239+
+ ForkNumber forknum, BlockNumber blocknum);
240+
+extern PGDLLIMPORT mdextend_hook_type mdextend_hook;
241+
+typedef void (*mdwrite_hook_type) (RelFileNodeBackend smgr_rnode,
242+
+ ForkNumber forknum, BlockNumber blocknum);
243+
+extern PGDLLIMPORT mdwrite_hook_type mdwrite_hook;
244+
+
245+
/* md storage manager functionality */
246+
extern void mdinit(void);
247+
extern void mdopen(SMgrRelation reln);
248+
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
249+
index 9737e1eb67c..914ad86328f 100644
250+
--- a/src/include/storage/sync.h
251+
+++ b/src/include/storage/sync.h
252+
@@ -55,6 +55,9 @@ typedef struct FileTag
253+
uint32 segno;
254+
} FileTag;
255+
256+
+typedef void (*ProcessSyncRequests_hook_type) (void);
257+
+extern PGDLLIMPORT ProcessSyncRequests_hook_type ProcessSyncRequests_hook;
258+
+
259+
extern void InitSync(void);
260+
extern void SyncPreCheckpoint(void);
261+
extern void SyncPostCheckpoint(void);

0 commit comments

Comments
 (0)