Skip to content

Commit 4abb1c2

Browse files
authored
Merge pull request #3 from postgrespro/travis_rel11
add basic tests to check compatibility with REL_11 in travis
2 parents 89d827c + 335e0f3 commit 4abb1c2

File tree

4 files changed

+268
-11
lines changed

4 files changed

+268
-11
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ env:
2727
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE TEST_CASE=all MODE=paranoia
2828
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE TEST_CASE=test_ptrack_multiple_segments TEST_REPEATS=5 MODE=paranoia
2929
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE TEST_CASE=test_ptrack_eat_my_data TEST_REPEATS=4
30+
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE TEST_CASE=tap
31+
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE TEST_CASE=tap MODE=legacy

codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
codecov:
22
notify:
3-
after_n_builds: 5 # keep in sync with .travis.yml number of builds
3+
after_n_builds: 8 # keep in sync with .travis.yml number of builds
44

55
# datapagemap.c/.h are copied from Postgres, so let's remove it
66
# from report. Otherwise, we would have to remove some currently
+263
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
2+
index 3e53b3df6fb..f76bfc2a646 100644
3+
--- a/src/backend/replication/basebackup.c
4+
+++ b/src/backend/replication/basebackup.c
5+
@@ -209,6 +209,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+
@@ -224,6 +231,10 @@ static const struct exclude_list_item noChecksumFiles[] = {
20+
{"pg_filenode.map", false},
21+
{"pg_internal.init", true},
22+
{"PG_VERSION", false},
23+
+ {"ptrack.map.mmap", false},
24+
+ {"ptrack.map", false},
25+
+ {"ptrack.map.tmp", false},
26+
+
27+
#ifdef EXEC_BACKEND
28+
{"config_exec_params", true},
29+
#endif
30+
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
31+
index 4a0d23b11e3..d59009a4c8c 100644
32+
--- a/src/backend/storage/file/copydir.c
33+
+++ b/src/backend/storage/file/copydir.c
34+
@@ -27,6 +27,8 @@
35+
#include "miscadmin.h"
36+
#include "pgstat.h"
37+
38+
+copydir_hook_type copydir_hook = NULL;
39+
+
40+
/*
41+
* copydir: copy a directory
42+
*
43+
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
44+
}
45+
FreeDir(xldir);
46+
47+
+ if (copydir_hook)
48+
+ copydir_hook(todir);
49+
+
50+
/*
51+
* Be paranoid here and fsync all files to ensure the copy is really done.
52+
* But if fsync is disabled, we're done.
53+
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
54+
index 200cc7f657a..d0dcb5c0287 100644
55+
--- a/src/backend/storage/smgr/md.c
56+
+++ b/src/backend/storage/smgr/md.c
57+
@@ -39,6 +39,7 @@
58+
#include "utils/memutils.h"
59+
#include "pg_trace.h"
60+
61+
+ProcessSyncRequests_hook_type ProcessSyncRequests_hook = NULL;
62+
63+
/* intervals for calling AbsorbFsyncRequests in mdsync and mdpostckpt */
64+
#define FSYNCS_PER_ABSORB 10
65+
@@ -114,6 +115,8 @@ typedef struct _MdfdVec
66+
67+
static MemoryContext MdCxt; /* context for all MdfdVec objects */
68+
69+
+mdextend_hook_type mdextend_hook = NULL;
70+
+mdwrite_hook_type mdwrite_hook = NULL;
71+
72+
/*
73+
* In some contexts (currently, standalone backends and the checkpointer)
74+
@@ -558,6 +561,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
75+
register_dirty_segment(reln, forknum, v);
76+
77+
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
78+
+
79+
+ if (mdextend_hook)
80+
+ mdextend_hook(reln->smgr_rnode, forknum, blocknum);
81+
}
82+
83+
/*
84+
@@ -851,6 +857,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
85+
86+
if (!skipFsync && !SmgrIsTemp(reln))
87+
register_dirty_segment(reln, forknum, v);
88+
+
89+
+ if (mdwrite_hook)
90+
+ mdwrite_hook(reln->smgr_rnode, forknum, blocknum);
91+
}
92+
93+
/*
94+
@@ -1329,6 +1338,9 @@ mdsync(void)
95+
CheckpointStats.ckpt_longest_sync = longest;
96+
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
97+
98+
+ if (ProcessSyncRequests_hook)
99+
+ ProcessSyncRequests_hook();
100+
+
101+
/* Flag successful completion of mdsync */
102+
mdsync_in_progress = false;
103+
}
104+
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
105+
index 6fb403a5a8a..6e31ccb3e0f 100644
106+
--- a/src/bin/pg_resetwal/pg_resetwal.c
107+
+++ b/src/bin/pg_resetwal/pg_resetwal.c
108+
@@ -84,6 +84,7 @@ static void RewriteControlFile(void);
109+
static void FindEndOfXLOG(void);
110+
static void KillExistingXLOG(void);
111+
static void KillExistingArchiveStatus(void);
112+
+static void KillExistingPtrack(void);
113+
static void WriteEmptyXLOG(void);
114+
static void usage(void);
115+
116+
@@ -516,6 +517,7 @@ main(int argc, char *argv[])
117+
RewriteControlFile();
118+
KillExistingXLOG();
119+
KillExistingArchiveStatus();
120+
+ KillExistingPtrack();
121+
WriteEmptyXLOG();
122+
123+
printf(_("Write-ahead log reset\n"));
124+
@@ -1201,6 +1203,57 @@ KillExistingArchiveStatus(void)
125+
}
126+
}
127+
128+
+/*
129+
+ * Remove existing ptrack files
130+
+ */
131+
+static void
132+
+KillExistingPtrack(void)
133+
+{
134+
+#define PTRACKDIR "global"
135+
+
136+
+ DIR *xldir;
137+
+ struct dirent *xlde;
138+
+ char path[MAXPGPATH + sizeof(PTRACKDIR)];
139+
+
140+
+ xldir = opendir(PTRACKDIR);
141+
+ if (xldir == NULL)
142+
+ {
143+
+ fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
144+
+ progname, PTRACKDIR, strerror(errno));
145+
+ exit(1);
146+
+ }
147+
+
148+
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
149+
+ {
150+
+ if (strcmp(xlde->d_name, "ptrack.map.mmap") == 0 ||
151+
+ strcmp(xlde->d_name, "ptrack.map") == 0 ||
152+
+ strcmp(xlde->d_name, "ptrack.map.tmp") == 0)
153+
+ {
154+
+ snprintf(path, sizeof(path), "%s/%s", PTRACKDIR, xlde->d_name);
155+
+ if (unlink(path) < 0)
156+
+ {
157+
+ fprintf(stderr, _("%s: could not delete file \"%s\": %s\n"),
158+
+ progname, path, strerror(errno));
159+
+ exit(1);
160+
+ }
161+
+ }
162+
+ }
163+
+
164+
+ if (errno)
165+
+ {
166+
+ fprintf(stderr, _("%s: could not read directory \"%s\": %s\n"),
167+
+ progname, PTRACKDIR, strerror(errno));
168+
+ exit(1);
169+
+ }
170+
+
171+
+ if (closedir(xldir))
172+
+ {
173+
+ fprintf(stderr, _("%s: could not close directory \"%s\": %s\n"),
174+
+ progname, PTRACKDIR, strerror(errno));
175+
+ exit(1);
176+
+ }
177+
+}
178+
+
179+
180+
/*
181+
* Write an empty XLOG file, containing only the checkpoint record
182+
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
183+
index 197163d5544..fc846e78175 100644
184+
--- a/src/bin/pg_rewind/filemap.c
185+
+++ b/src/bin/pg_rewind/filemap.c
186+
@@ -118,6 +118,10 @@ static const struct exclude_list_item excludeFiles[] =
187+
{"postmaster.pid", false},
188+
{"postmaster.opts", false},
189+
190+
+ {"ptrack.map.mmap", false},
191+
+ {"ptrack.map", false},
192+
+ {"ptrack.map.tmp", false},
193+
+
194+
/* end of list */
195+
{NULL, false}
196+
};
197+
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
198+
index 80241455357..50dca7bf6f4 100644
199+
--- a/src/include/miscadmin.h
200+
+++ b/src/include/miscadmin.h
201+
@@ -367,7 +367,7 @@ typedef enum ProcessingMode
202+
NormalProcessing /* normal processing */
203+
} ProcessingMode;
204+
205+
-extern ProcessingMode Mode;
206+
+extern PGDLLIMPORT ProcessingMode Mode;
207+
208+
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
209+
#define IsInitProcessingMode() (Mode == InitProcessing)
210+
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
211+
index 9a26295c8e8..dc72b27a10d 100644
212+
--- a/src/include/port/pg_crc32c.h
213+
+++ b/src/include/port/pg_crc32c.h
214+
@@ -69,8 +69,11 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
215+
#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
216+
217+
extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
218+
-extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
219+
-
220+
+extern
221+
+#ifndef FRONTEND
222+
+PGDLLIMPORT
223+
+#endif
224+
+pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
225+
#ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
226+
extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
227+
#endif
228+
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
229+
index 4fef3e21072..e55430879c3 100644
230+
--- a/src/include/storage/copydir.h
231+
+++ b/src/include/storage/copydir.h
232+
@@ -13,6 +13,9 @@
233+
#ifndef COPYDIR_H
234+
#define COPYDIR_H
235+
236+
+typedef void (*copydir_hook_type) (const char *path);
237+
+extern PGDLLIMPORT copydir_hook_type copydir_hook;
238+
+
239+
extern void copydir(char *fromdir, char *todir, bool recurse);
240+
extern void copy_file(char *fromfile, char *tofile);
241+
242+
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
243+
index 0298ed1a2bc..24c684771d0 100644
244+
--- a/src/include/storage/smgr.h
245+
+++ b/src/include/storage/smgr.h
246+
@@ -116,6 +116,17 @@ extern void AtEOXact_SMgr(void);
247+
/* internals: move me elsewhere -- ay 7/94 */
248+
249+
/* in md.c */
250+
+
251+
+typedef void (*mdextend_hook_type) (RelFileNodeBackend smgr_rnode,
252+
+ ForkNumber forknum, BlockNumber blocknum);
253+
+extern PGDLLIMPORT mdextend_hook_type mdextend_hook;
254+
+typedef void (*mdwrite_hook_type) (RelFileNodeBackend smgr_rnode,
255+
+ ForkNumber forknum, BlockNumber blocknum);
256+
+extern PGDLLIMPORT mdwrite_hook_type mdwrite_hook;
257+
+
258+
+typedef void (*ProcessSyncRequests_hook_type) (void);
259+
+extern PGDLLIMPORT ProcessSyncRequests_hook_type ProcessSyncRequests_hook;
260+
+
261+
extern void mdinit(void);
262+
extern void mdclose(SMgrRelation reln, ForkNumber forknum);
263+
extern void mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);

ptrack.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#if PG_VERSION_NUM >= 120000
4747
#include "storage/md.h"
4848
#endif
49+
#include "storage/smgr.h"
4950
#include "storage/reinit.h"
5051
#include "utils/builtins.h"
5152
#include "utils/guc.h"
@@ -64,9 +65,7 @@ int ptrack_map_size_tmp;
6465
static copydir_hook_type prev_copydir_hook = NULL;
6566
static mdwrite_hook_type prev_mdwrite_hook = NULL;
6667
static mdextend_hook_type prev_mdextend_hook = NULL;
67-
#if PG_VERSION_NUM >= 120000
6868
static ProcessSyncRequests_hook_type prev_ProcessSyncRequests_hook = NULL;
69-
#endif
7069

7170
void _PG_init(void);
7271
void _PG_fini(void);
@@ -76,9 +75,8 @@ static void ptrack_mdwrite_hook(RelFileNodeBackend smgr_rnode,
7675
ForkNumber forkno, BlockNumber blkno);
7776
static void ptrack_mdextend_hook(RelFileNodeBackend smgr_rnode,
7877
ForkNumber forkno, BlockNumber blkno);
79-
#if PG_VERSION_NUM >= 120000
8078
static void ptrack_ProcessSyncRequests_hook(void);
81-
#endif
79+
8280
static void ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid);
8381
static int ptrack_filelist_getnext(PtScanCtx * ctx);
8482

@@ -120,10 +118,8 @@ _PG_init(void)
120118
mdwrite_hook = ptrack_mdwrite_hook;
121119
prev_mdextend_hook = mdextend_hook;
122120
mdextend_hook = ptrack_mdextend_hook;
123-
#if PG_VERSION_NUM >= 120000
124121
prev_ProcessSyncRequests_hook = ProcessSyncRequests_hook;
125122
ProcessSyncRequests_hook = ptrack_ProcessSyncRequests_hook;
126-
#endif
127123
}
128124

129125
/*
@@ -136,9 +132,7 @@ _PG_fini(void)
136132
copydir_hook = prev_copydir_hook;
137133
mdwrite_hook = prev_mdwrite_hook;
138134
mdextend_hook = prev_mdextend_hook;
139-
#if PG_VERSION_NUM >= 120000
140135
ProcessSyncRequests_hook = prev_ProcessSyncRequests_hook;
141-
#endif
142136
}
143137

144138
/*
@@ -218,7 +212,6 @@ ptrack_mdextend_hook(RelFileNodeBackend smgr_rnode,
218212
prev_mdextend_hook(smgr_rnode, forknum, blocknum);
219213
}
220214

221-
#if PG_VERSION_NUM >= 120000
222215
static void
223216
ptrack_ProcessSyncRequests_hook()
224217
{
@@ -227,7 +220,6 @@ ptrack_ProcessSyncRequests_hook()
227220
if (prev_ProcessSyncRequests_hook)
228221
prev_ProcessSyncRequests_hook();
229222
}
230-
#endif
231223

232224
/*
233225
* Recursively walk through the path and add all data files to filelist.

0 commit comments

Comments
 (0)