1
1
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
2
- index3e53b3df6fb..f76bfc2a646 100644
2
+ indexba4b47443f..62baf8ab4f 100644
3
3
--- a/src/backend/replication/basebackup.c
4
4
+++ b/src/backend/replication/basebackup.c
5
5
@@ -209,6 +209,13 @@ static const struct exclude_list_item excludeFiles[] =
@@ -28,7 +28,7 @@ index 3e53b3df6fb..f76bfc2a646 100644
28
28
{"config_exec_params", true},
29
29
#endif
30
30
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
31
- index4a0d23b11e3..d59009a4c8c 100644
31
+ index4a0d23b11e..d59009a4c8 100644
32
32
--- a/src/backend/storage/file/copydir.c
33
33
+++ b/src/backend/storage/file/copydir.c
34
34
@@ -27,6 +27,8 @@
@@ -51,7 +51,7 @@ index 4a0d23b11e3..d59009a4c8c 100644
51
51
* Be paranoid here and fsync all files to ensure the copy is really done.
52
52
* But if fsync is disabled, we're done.
53
53
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
54
- index200cc7f657a..d0dcb5c0287 100644
54
+ index5418452261..3332a3c717 100644
55
55
--- a/src/backend/storage/smgr/md.c
56
56
+++ b/src/backend/storage/smgr/md.c
57
57
@@ -39,6 +39,7 @@
@@ -71,7 +71,7 @@ index 200cc7f657a..d0dcb5c0287 100644
71
71
72
72
/*
73
73
* In some contexts (currently, standalone backends and the checkpointer)
74
- @@ -558 ,6 +561 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
74
+ @@ -603 ,6 +606 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
75
75
register_dirty_segment(reln, forknum, v);
76
76
77
77
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -81,7 +81,7 @@ index 200cc7f657a..d0dcb5c0287 100644
81
81
}
82
82
83
83
/*
84
- @@ -851 ,6 +857 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
84
+ @@ -896 ,6 +902 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
85
85
86
86
if (!skipFsync && !SmgrIsTemp(reln))
87
87
register_dirty_segment(reln, forknum, v);
@@ -91,7 +91,7 @@ index 200cc7f657a..d0dcb5c0287 100644
91
91
}
92
92
93
93
/*
94
- @@ -1329 ,6 +1338 ,9 @@ mdsync(void)
94
+ @@ -1374 ,6 +1383 ,9 @@ mdsync(void)
95
95
CheckpointStats.ckpt_longest_sync = longest;
96
96
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
97
97
@@ -101,27 +101,124 @@ index 200cc7f657a..d0dcb5c0287 100644
101
101
/* Flag successful completion of mdsync */
102
102
mdsync_in_progress = false;
103
103
}
104
+ diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
105
+ index c7f3ee733d..837ee73217 100644
106
+ --- a/src/backend/utils/init/miscinit.c
107
+ +++ b/src/backend/utils/init/miscinit.c
108
+ @@ -74,6 +74,11 @@ static Latch LocalLatchData;
109
+
110
+ boolIgnoreSystemIndexes = false;
111
+
112
+ + /* ----------------------------------------------------------------
113
+ + *Ptrack functions support
114
+ + * ----------------------------------------------------------------
115
+ + */
116
+ + static void check_use_ptrack(const char *libraries);
117
+
118
+ /* ----------------------------------------------------------------
119
+ *database path / name support stuff
120
+ @@ -1601,6 +1606,8 @@ process_shared_preload_libraries(void)
121
+ "shared_preload_libraries",
122
+ false);
123
+ process_shared_preload_libraries_in_progress = false;
124
+ +
125
+ + check_use_ptrack(shared_preload_libraries_string);
126
+ }
127
+
128
+ /*
129
+ @@ -1631,3 +1638,71 @@ pg_bindtextdomain(const char *domain)
130
+ }
131
+ #endif
132
+ }
133
+ +
134
+ + /*-------------------------------------------------------------------------
135
+ + *Ptrack functions support
136
+ + *-------------------------------------------------------------------------
137
+ + */
138
+ +
139
+ + /* Persistent copy of ptrack.map to restore after crash */
140
+ + #define PTRACK_PATH "global/ptrack.map"
141
+ + /* Used for atomical crash-safe update of ptrack.map */
142
+ + #define PTRACK_PATH_TMP "global/ptrack.map.tmp"
143
+ +
144
+ + /*
145
+ + * Check that path is accessible by us and return true if it is
146
+ + * not a directory.
147
+ + */
148
+ + static bool
149
+ + ptrack_file_exists(const char *path)
150
+ + {
151
+ + struct stat st;
152
+ +
153
+ + Assert(path != NULL);
154
+ +
155
+ + if (stat(path, &st) == 0)
156
+ + return S_ISDIR(st.st_mode) ? false : true;
157
+ + else if (!(errno == ENOENT || errno == ENOTDIR || errno == EACCES))
158
+ + ereport(ERROR,
159
+ + (errcode_for_file_access(),
160
+ + errmsg("could not access file \"%s\": %m", path)));
161
+ +
162
+ + return false;
163
+ + }
164
+ +
165
+ + /*
166
+ + * Delete ptrack files when ptrack is disabled.
167
+ + *
168
+ + * This is performed by postmaster at start,
169
+ + * so that there are no concurrent delete issues.
170
+ + */
171
+ + static void
172
+ + ptrackCleanFiles(void)
173
+ + {
174
+ + charptrack_path[MAXPGPATH];
175
+ + charptrack_path_tmp[MAXPGPATH];
176
+ +
177
+ + sprintf(ptrack_path, "%s/%s", DataDir, PTRACK_PATH);
178
+ + sprintf(ptrack_path_tmp, "%s/%s", DataDir, PTRACK_PATH_TMP);
179
+ +
180
+ + elog(DEBUG1, "ptrack: clean map files");
181
+ +
182
+ + if (ptrack_file_exists(ptrack_path_tmp))
183
+ + durable_unlink(ptrack_path_tmp, LOG);
184
+ +
185
+ + if (ptrack_file_exists(ptrack_path))
186
+ + durable_unlink(ptrack_path, LOG);
187
+ + }
188
+ +
189
+ + static void
190
+ + check_use_ptrack(const char *libraries)
191
+ + {
192
+ + /* We need to delete the ptrack.map file when ptrack was turned off */
193
+ + if (strstr(shared_preload_libraries_string, "ptrack") == NULL)
194
+ + {
195
+ + ptrackCleanFiles();
196
+ + }
197
+ + }
198
+ +
199
+ + #undef PTRACK_PATH
200
+ + #undef PTRACK_PATH_TMP
104
201
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
105
- index6fb403a5a8a..6e31ccb3e0f 100644
202
+ index611edf6ade..ec1c1212bd 100644
106
203
--- a/src/bin/pg_resetwal/pg_resetwal.c
107
204
+++ b/src/bin/pg_resetwal/pg_resetwal.c
108
- @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void);
205
+ @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void);
109
206
static void FindEndOfXLOG(void);
110
207
static void KillExistingXLOG(void);
111
208
static void KillExistingArchiveStatus(void);
112
209
+ static void KillExistingPtrack(void);
113
210
static void WriteEmptyXLOG(void);
114
211
static void usage(void);
115
212
116
- @@ -516 ,6 +517 ,7 @@ main(int argc, char *argv[])
213
+ @@ -525 ,6 +526 ,7 @@ main(int argc, char *argv[])
117
214
RewriteControlFile();
118
215
KillExistingXLOG();
119
216
KillExistingArchiveStatus();
120
217
+ KillExistingPtrack();
121
218
WriteEmptyXLOG();
122
219
123
220
printf(_("Write-ahead log reset\n"));
124
- @@ -1201 ,6 +1203 ,57 @@ KillExistingArchiveStatus(void)
221
+ @@ -1210 ,6 +1212 ,57 @@ KillExistingArchiveStatus(void)
125
222
}
126
223
}
127
224
@@ -180,7 +277,7 @@ index 6fb403a5a8a..6e31ccb3e0f 100644
180
277
/*
181
278
* Write an empty XLOG file, containing only the checkpoint record
182
279
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
183
- index197163d5544..fc846e78175 100644
280
+ index8ea7fafa27..997168fcac 100644
184
281
--- a/src/bin/pg_rewind/filemap.c
185
282
+++ b/src/bin/pg_rewind/filemap.c
186
283
@@ -118,6 +118,10 @@ static const struct exclude_list_item excludeFiles[] =
@@ -195,10 +292,10 @@ index 197163d5544..fc846e78175 100644
195
292
{NULL, false}
196
293
};
197
294
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
198
- index80241455357..50dca7bf6f4 100644
295
+ index7c9f319b67..1e29827030 100644
199
296
--- a/src/include/miscadmin.h
200
297
+++ b/src/include/miscadmin.h
201
- @@ -367 ,7 +367 ,7 @@ typedef enum ProcessingMode
298
+ @@ -379 ,7 +379 ,7 @@ typedef enum ProcessingMode
202
299
NormalProcessing/* normal processing */
203
300
} ProcessingMode;
204
301
@@ -208,7 +305,7 @@ index 80241455357..50dca7bf6f4 100644
208
305
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
209
306
#define IsInitProcessingMode()(Mode == InitProcessing)
210
307
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
211
- index4fef3e21072..e55430879c3 100644
308
+ index4fef3e2107..e55430879c 100644
212
309
--- a/src/include/storage/copydir.h
213
310
+++ b/src/include/storage/copydir.h
214
311
@@ -13,6 +13,9 @@
@@ -222,7 +319,7 @@ index 4fef3e21072..e55430879c3 100644
222
319
extern void copy_file(char *fromfile, char *tofile);
223
320
224
321
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
225
- index0298ed1a2bc..24c684771d0 100644
322
+ index0298ed1a2b..24c684771d 100644
226
323
--- a/src/include/storage/smgr.h
227
324
+++ b/src/include/storage/smgr.h
228
325
@@ -116,6 +116,17 @@ extern void AtEOXact_SMgr(void);
@@ -244,7 +341,7 @@ index 0298ed1a2bc..24c684771d0 100644
244
341
extern void mdclose(SMgrRelation reln, ForkNumber forknum);
245
342
extern void mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
246
343
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
247
- indexb52baa90988..74870c048db 100644
344
+ indexb52baa9098..74870c048d 100644
248
345
--- a/src/tools/msvc/Mkvcbuild.pm
249
346
+++ b/src/tools/msvc/Mkvcbuild.pm
250
347
@@ -33,7 +33,7 @@ my @unlink_on_exit;