1
- commit a14ac459d71528c64df00c693e9c71ac70d3ba29
2
- Author: anastasia <
[email protected] >
3
- Date: Mon Oct 19 14:53:06 2020 +0300
4
-
5
- add ptrack 2.0
6
-
7
1
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
8
- index 50ae1f16d0..721b926ad2 100644
2
+ index 5244823ff85..160889b4a04 100644
9
3
--- a/src/backend/replication/basebackup.c
10
4
+++ b/src/backend/replication/basebackup.c
11
- @@ -233 ,6 +233 ,13 @@ static const struct exclude_list_item excludeFiles[] =
5
+ @@ -197 ,6 +197 ,13 @@ static const struct exclude_list_item excludeFiles[] =
12
6
{"postmaster.pid", false},
13
7
{"postmaster.opts", false},
14
8
@@ -22,7 +16,7 @@ index 50ae1f16d0..721b926ad2 100644
22
16
/* end of list */
23
17
{NULL, false}
24
18
};
25
- @@ -248 ,6 +255 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
19
+ @@ -212 ,6 +219 ,11 @@ static const struct exclude_list_item noChecksumFiles[] = {
26
20
{"pg_filenode.map", false},
27
21
{"pg_internal.init", true},
28
22
{"PG_VERSION", false},
@@ -35,7 +29,7 @@ index 50ae1f16d0..721b926ad2 100644
35
29
{"config_exec_params", true},
36
30
#endif
37
31
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
38
- index 0cf598dd0c..c9c44a4ae7 100644
32
+ index 658fd95ba95..eee38eba176 100644
39
33
--- a/src/backend/storage/file/copydir.c
40
34
+++ b/src/backend/storage/file/copydir.c
41
35
@@ -27,6 +27,8 @@
@@ -58,7 +52,7 @@ index 0cf598dd0c..c9c44a4ae7 100644
58
52
* Be paranoid here and fsync all files to ensure the copy is really done.
59
53
* But if fsync is disabled, we're done.
60
54
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
61
- index 0eacd461cd..c2ef404a1a 100644
55
+ index 43edaf5d873..bbaf7500944 100644
62
56
--- a/src/backend/storage/smgr/md.c
63
57
+++ b/src/backend/storage/smgr/md.c
64
58
@@ -87,6 +87,8 @@ typedef struct _MdfdVec
@@ -70,7 +64,7 @@ index 0eacd461cd..c2ef404a1a 100644
70
64
71
65
/* Populate a file tag describing an md.c segment file. */
72
66
#define INIT_MD_FILETAG(a,xx_rnode,xx_forknum,xx_segno) \
73
- @@ -435 ,6 +437 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
67
+ @@ -467 ,6 +469 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
74
68
register_dirty_segment(reln, forknum, v);
75
69
76
70
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -80,7 +74,7 @@ index 0eacd461cd..c2ef404a1a 100644
80
74
}
81
75
82
76
/*
83
- @@ -721 ,6 +726 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
77
+ @@ -756 ,6 +761 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
84
78
85
79
if (!skipFsync && !SmgrIsTemp(reln))
86
80
register_dirty_segment(reln, forknum, v);
@@ -91,10 +85,10 @@ index 0eacd461cd..c2ef404a1a 100644
91
85
92
86
/*
93
87
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
94
- index 3ded2cdd71..3a596a59f7 100644
88
+ index e1fb6310038..76d75680b31 100644
95
89
--- a/src/backend/storage/sync/sync.c
96
90
+++ b/src/backend/storage/sync/sync.c
97
- @@ -75 ,6 +75 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
91
+ @@ -81 ,6 +81 ,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
98
92
static CycleCtr sync_cycle_ctr = 0;
99
93
static CycleCtr checkpoint_cycle_ctr = 0;
100
94
@@ -103,7 +97,7 @@ index 3ded2cdd71..3a596a59f7 100644
103
97
/* Intervals for calling AbsorbSyncRequests */
104
98
#define FSYNCS_PER_ABSORB 10
105
99
#define UNLINKS_PER_ABSORB 10
106
- @@ -420 ,6 +422 ,9 @@ ProcessSyncRequests(void)
100
+ @@ -477 ,6 +479 ,9 @@ ProcessSyncRequests(void)
107
101
CheckpointStats.ckpt_longest_sync = longest;
108
102
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
109
103
@@ -113,23 +107,11 @@ index 3ded2cdd71..3a596a59f7 100644
113
107
/* Flag successful completion of ProcessSyncRequests */
114
108
sync_in_progress = false;
115
109
}
116
- diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
117
- index 1683629ee3..d2fc154576 100644
118
- --- a/src/backend/utils/misc/guc.c
119
- +++ b/src/backend/utils/misc/guc.c
120
- @@ -620,7 +620,6 @@ static char *recovery_target_xid_string;
121
- static char *recovery_target_name_string;
122
- static char *recovery_target_lsn_string;
123
-
124
- -
125
- /* should be static, but commands/variable.c needs to get at this */
126
- char *role_string;
127
-
128
110
diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
129
- index ffdc23945c..7ae95866ce 100644
111
+ index 21dfe1b6ee5..266ac1ef40a 100644
130
112
--- a/src/bin/pg_checksums/pg_checksums.c
131
113
+++ b/src/bin/pg_checksums/pg_checksums.c
132
- @@ -114 ,6 +114 ,11 @@ static const struct exclude_list_item skip[] = {
114
+ @@ -118 ,6 +118 ,11 @@ static const struct exclude_list_item skip[] = {
133
115
{"pg_filenode.map", false},
134
116
{"pg_internal.init", true},
135
117
{"PG_VERSION", false},
@@ -142,27 +124,27 @@ index ffdc23945c..7ae95866ce 100644
142
124
{"config_exec_params", true},
143
125
#endif
144
126
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
145
- index 233441837f..cf7bd073bf 100644
127
+ index d4772a29650..3318f64359d 100644
146
128
--- a/src/bin/pg_resetwal/pg_resetwal.c
147
129
+++ b/src/bin/pg_resetwal/pg_resetwal.c
148
- @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void);
130
+ @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void);
149
131
static void FindEndOfXLOG(void);
150
132
static void KillExistingXLOG(void);
151
133
static void KillExistingArchiveStatus(void);
152
134
+ static void KillExistingPtrack(void);
153
135
static void WriteEmptyXLOG(void);
154
136
static void usage(void);
155
137
156
- @@ -513 ,6 +514 ,7 @@ main(int argc, char *argv[])
138
+ @@ -488 ,6 +489 ,7 @@ main(int argc, char *argv[])
157
139
RewriteControlFile();
158
140
KillExistingXLOG();
159
141
KillExistingArchiveStatus();
160
142
+ KillExistingPtrack();
161
143
WriteEmptyXLOG();
162
144
163
145
printf(_("Write-ahead log reset\n"));
164
- @@ -1102 ,6 +1104,53 @@ KillExistingArchiveStatus(void)
165
- }
146
+ @@ -1036 ,6 +1038,41 @@ KillExistingArchiveStatus(void)
147
+ pg_fatal("could not close directory \"%s\": %m", ARCHSTATDIR);
166
148
}
167
149
168
150
+ /*
@@ -173,16 +155,13 @@ index 233441837f..cf7bd073bf 100644
173
155
+ {
174
156
+ #define PTRACKDIR "global"
175
157
+
176
- + DIR *xldir;
158
+ + DIR *xldir;
177
159
+ struct dirent *xlde;
178
- + char path[MAXPGPATH + sizeof(PTRACKDIR)];
160
+ + char path[MAXPGPATH + sizeof(PTRACKDIR)];
179
161
+
180
162
+ xldir = opendir(PTRACKDIR);
181
163
+ if (xldir == NULL)
182
- + {
183
- + pg_log_error("could not open directory \"%s\": %m", PTRACKDIR);
184
- + exit(1);
185
- + }
164
+ + pg_fatal("could not open directory \"%s\": %m", PTRACKDIR);
186
165
+
187
166
+ while (errno = 0, (xlde = readdir(xldir)) != NULL)
188
167
+ {
@@ -192,34 +171,25 @@ index 233441837f..cf7bd073bf 100644
192
171
+ {
193
172
+ snprintf(path, sizeof(path), "%s/%s", PTRACKDIR, xlde->d_name);
194
173
+ if (unlink(path) < 0)
195
- + {
196
- + pg_log_error("could not delete file \"%s\": %m", path);
197
- + exit(1);
198
- + }
174
+ + pg_fatal("could not delete file \"%s\": %m", path);
199
175
+ }
200
176
+ }
201
177
+
202
178
+ if (errno)
203
- + {
204
- + pg_log_error("could not read directory \"%s\": %m", PTRACKDIR);
205
- + exit(1);
206
- + }
179
+ + pg_fatal("could not read directory \"%s\": %m", PTRACKDIR);
207
180
+
208
181
+ if (closedir(xldir))
209
- + {
210
- + pg_log_error("could not close directory \"%s\": %m", PTRACKDIR);
211
- + exit(1);
212
- + }
182
+ + pg_fatal("could not close directory \"%s\": %m", PTRACKDIR);
213
183
+ }
214
184
+
215
185
216
186
/*
217
187
* Write an empty XLOG file, containing only the checkpoint record
218
188
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
219
- index fbb97b5cf1..6cd7f2ae3e 100644
189
+ index 62529310415..b496f54fb06 100644
220
190
--- a/src/bin/pg_rewind/filemap.c
221
191
+++ b/src/bin/pg_rewind/filemap.c
222
- @@ -124 ,6 +124 ,10 @@ static const struct exclude_list_item excludeFiles[] =
192
+ @@ -157 ,6 +157 ,10 @@ static const struct exclude_list_item excludeFiles[] =
223
193
{"postmaster.pid", false},
224
194
{"postmaster.opts", false},
225
195
@@ -230,39 +200,21 @@ index fbb97b5cf1..6cd7f2ae3e 100644
230
200
/* end of list */
231
201
{NULL, false}
232
202
};
233
- diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
234
- index 72e3352398..5c2e016501 100644
235
- --- a/src/include/miscadmin.h
236
- +++ b/src/include/miscadmin.h
237
- @@ -388,7 +388,7 @@ typedef enum ProcessingMode
238
- NormalProcessing /* normal processing */
239
- } ProcessingMode;
240
-
241
- - extern ProcessingMode Mode;
242
- + extern PGDLLIMPORT ProcessingMode Mode;
243
-
244
- #define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
245
- #define IsInitProcessingMode() (Mode == InitProcessing)
246
203
diff --git a/src/include/port/pg_crc32c.h b/src/include/port/pg_crc32c.h
247
- index 3c6f906683..a7355f7ad1 100644
204
+ index d7668651ba8..33994a27f5f 100644
248
205
--- a/src/include/port/pg_crc32c.h
249
206
+++ b/src/include/port/pg_crc32c.h
250
- @@ -69,8 +69,11 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
207
+ @@ -69,7 +69,7 @@ extern pg_crc32c pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t le
251
208
#define FIN_CRC32C(crc) ((crc) ^= 0xFFFFFFFF)
252
209
253
210
extern pg_crc32c pg_comp_crc32c_sb8(pg_crc32c crc, const void *data, size_t len);
254
211
- extern pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len);
255
- -
256
- + extern
257
- + #ifndef FRONTEND
258
- + PGDLLIMPORT
259
- + #endif
260
- + 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
+
261
214
#ifdef USE_SSE42_CRC32C_WITH_RUNTIME_CHECK
262
215
extern pg_crc32c pg_comp_crc32c_sse42(pg_crc32c crc, const void *data, size_t len);
263
- #endif
264
216
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
265
- index 5d28f59c1d..0d3f04d8af 100644
217
+ index 50a26edeb06..af1602f5154 100644
266
218
--- a/src/include/storage/copydir.h
267
219
+++ b/src/include/storage/copydir.h
268
220
@@ -13,6 +13,9 @@
@@ -276,7 +228,7 @@ index 5d28f59c1d..0d3f04d8af 100644
276
228
extern void copy_file(char *fromfile, char *tofile);
277
229
278
230
diff --git a/src/include/storage/md.h b/src/include/storage/md.h
279
- index 07fd1bb7d0..5294811bc8 100644
231
+ index ffffa40db71..3ff98e0bf01 100644
280
232
--- a/src/include/storage/md.h
281
233
+++ b/src/include/storage/md.h
282
234
@@ -19,6 +19,13 @@
@@ -287,17 +239,17 @@ index 07fd1bb7d0..5294811bc8 100644
287
239
+ ForkNumber forknum, BlockNumber blocknum);
288
240
+ extern PGDLLIMPORT mdextend_hook_type mdextend_hook;
289
241
+ typedef void (*mdwrite_hook_type) (RelFileNodeBackend smgr_rnode,
290
- + ForkNumber forknum, BlockNumber blocknum);
242
+ + ForkNumber forknum, BlockNumber blocknum);
291
243
+ extern PGDLLIMPORT mdwrite_hook_type mdwrite_hook;
292
244
+
293
245
/* md storage manager functionality */
294
246
extern void mdinit(void);
295
247
extern void mdopen(SMgrRelation reln);
296
248
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
297
- index e16ab8e711..88da9686eb 100644
249
+ index 9737e1eb67c..914ad86328f 100644
298
250
--- a/src/include/storage/sync.h
299
251
+++ b/src/include/storage/sync.h
300
- @@ -50 ,6 +50 ,9 @@ typedef struct FileTag
252
+ @@ -55 ,6 +55 ,9 @@ typedef struct FileTag
301
253
uint32 segno;
302
254
} FileTag;
303
255
0 commit comments