1
- commit 5255ff7a6051f56689e0db2a0fa7e9a6e4086d66
2
- Author: Anton A. Melnikov <a.melnikov@postgrespro.ru>
3
- Date: Mon Nov 8 11:11:45 2021 +0300
4
-
5
- [PGPRO-5771] Add handler for COMP_CRC32C and restore pg_comp_crc32c pointer definition.
6
-
7
1
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
8
- index 3e53b3df6f..f76bfc2a64 100644
2
+ index 3e53b3df6fb..f76bfc2a646 100644
9
3
--- a/src/backend/replication/basebackup.c
10
4
+++ b/src/backend/replication/basebackup.c
11
5
@@ -209,6 +209,13 @@ static const struct exclude_list_item excludeFiles[] =
12
6
{"postmaster.pid", false},
13
7
{"postmaster.opts", false},
14
-
8
+
15
9
+ /*
16
10
+ * Skip all transient ptrack files, but do copy ptrack.map, since it may
17
11
+ * be successfully used immediately after backup. TODO: check, test?
@@ -34,13 +28,13 @@ index 3e53b3df6f..f76bfc2a64 100644
34
28
{"config_exec_params", true},
35
29
#endif
36
30
diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
37
- index 4a0d23b11e..d59009a4c8 100644
31
+ index 4a0d23b11e3..d59009a4c8c 100644
38
32
--- a/src/backend/storage/file/copydir.c
39
33
+++ b/src/backend/storage/file/copydir.c
40
34
@@ -27,6 +27,8 @@
41
35
#include "miscadmin.h"
42
36
#include "pgstat.h"
43
-
37
+
44
38
+ copydir_hook_type copydir_hook = NULL;
45
39
+
46
40
/*
@@ -49,88 +43,88 @@ index 4a0d23b11e..d59009a4c8 100644
49
43
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
50
44
}
51
45
FreeDir(xldir);
52
-
46
+
53
47
+ if (copydir_hook)
54
48
+ copydir_hook(todir);
55
49
+
56
50
/*
57
51
* Be paranoid here and fsync all files to ensure the copy is really done.
58
52
* But if fsync is disabled, we're done.
59
53
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
60
- index fa29e7041f..8bda639eda 100644
54
+ index 200cc7f657a..d0dcb5c0287 100644
61
55
--- a/src/backend/storage/smgr/md.c
62
56
+++ b/src/backend/storage/smgr/md.c
63
57
@@ -39,6 +39,7 @@
64
58
#include "utils/memutils.h"
65
59
#include "pg_trace.h"
66
-
60
+
67
61
+ ProcessSyncRequests_hook_type ProcessSyncRequests_hook = NULL;
68
-
62
+
69
63
/* intervals for calling AbsorbFsyncRequests in mdsync and mdpostckpt */
70
64
#define FSYNCS_PER_ABSORB 10
71
65
@@ -114,6 +115,8 @@ typedef struct _MdfdVec
72
-
66
+
73
67
static MemoryContext MdCxt; /* context for all MdfdVec objects */
74
-
68
+
75
69
+ mdextend_hook_type mdextend_hook = NULL;
76
70
+ mdwrite_hook_type mdwrite_hook = NULL;
77
-
71
+
78
72
/*
79
73
* In some contexts (currently, standalone backends and the checkpointer)
80
- @@ -600 ,6 +603 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
74
+ @@ -558 ,6 +561 ,9 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
81
75
register_dirty_segment(reln, forknum, v);
82
-
76
+
83
77
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
84
78
+
85
79
+ if (mdextend_hook)
86
80
+ mdextend_hook(reln->smgr_rnode, forknum, blocknum);
87
81
}
88
-
82
+
89
83
/*
90
- @@ -893 ,6 +899 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
91
-
84
+ @@ -851 ,6 +857 ,9 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
85
+
92
86
if (!skipFsync && !SmgrIsTemp(reln))
93
87
register_dirty_segment(reln, forknum, v);
94
88
+
95
89
+ if (mdwrite_hook)
96
90
+ mdwrite_hook(reln->smgr_rnode, forknum, blocknum);
97
91
}
98
-
92
+
99
93
/*
100
- @@ -1371 ,6 +1380 ,9 @@ mdsync(void)
94
+ @@ -1329 ,6 +1338 ,9 @@ mdsync(void)
101
95
CheckpointStats.ckpt_longest_sync = longest;
102
96
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
103
-
97
+
104
98
+ if (ProcessSyncRequests_hook)
105
99
+ ProcessSyncRequests_hook();
106
100
+
107
101
/* Flag successful completion of mdsync */
108
102
mdsync_in_progress = false;
109
103
}
110
104
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
111
- index 611edf6ade..ec1c1212bd 100644
105
+ index 6fb403a5a8a..6e31ccb3e0f 100644
112
106
--- a/src/bin/pg_resetwal/pg_resetwal.c
113
107
+++ b/src/bin/pg_resetwal/pg_resetwal.c
114
- @@ -85 ,6 +85 ,7 @@ static void RewriteControlFile(void);
108
+ @@ -84 ,6 +84 ,7 @@ static void RewriteControlFile(void);
115
109
static void FindEndOfXLOG(void);
116
110
static void KillExistingXLOG(void);
117
111
static void KillExistingArchiveStatus(void);
118
112
+ static void KillExistingPtrack(void);
119
113
static void WriteEmptyXLOG(void);
120
114
static void usage(void);
121
-
122
- @@ -525 ,6 +526 ,7 @@ main(int argc, char *argv[])
115
+
116
+ @@ -516 ,6 +517 ,7 @@ main(int argc, char *argv[])
123
117
RewriteControlFile();
124
118
KillExistingXLOG();
125
119
KillExistingArchiveStatus();
126
120
+ KillExistingPtrack();
127
121
WriteEmptyXLOG();
128
-
122
+
129
123
printf(_("Write-ahead log reset\n"));
130
- @@ -1210 ,6 +1212 ,57 @@ KillExistingArchiveStatus(void)
124
+ @@ -1201 ,6 +1203 ,57 @@ KillExistingArchiveStatus(void)
131
125
}
132
126
}
133
-
127
+
134
128
+ /*
135
129
+ * Remove existing ptrack files
136
130
+ */
@@ -182,17 +176,17 @@ index 611edf6ade..ec1c1212bd 100644
182
176
+ }
183
177
+ }
184
178
+
185
-
179
+
186
180
/*
187
181
* Write an empty XLOG file, containing only the checkpoint record
188
182
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
189
- index 8ea7fafa27..997168fcac 100644
183
+ index 197163d5544..fc846e78175 100644
190
184
--- a/src/bin/pg_rewind/filemap.c
191
185
+++ b/src/bin/pg_rewind/filemap.c
192
186
@@ -118,6 +118,10 @@ static const struct exclude_list_item excludeFiles[] =
193
187
{"postmaster.pid", false},
194
188
{"postmaster.opts", false},
195
-
189
+
196
190
+ {"ptrack.map.mmap", false},
197
191
+ {"ptrack.map", false},
198
192
+ {"ptrack.map.tmp", false},
@@ -201,77 +195,57 @@ index 8ea7fafa27..997168fcac 100644
201
195
{NULL, false}
202
196
};
203
197
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
204
- index 7c9f319b67..1e29827030 100644
198
+ index 80241455357..50dca7bf6f4 100644
205
199
--- a/src/include/miscadmin.h
206
200
+++ b/src/include/miscadmin.h
207
- @@ -379 ,7 +379 ,7 @@ typedef enum ProcessingMode
201
+ @@ -367 ,7 +367 ,7 @@ typedef enum ProcessingMode
208
202
NormalProcessing /* normal processing */
209
203
} ProcessingMode;
210
-
204
+
211
205
- extern ProcessingMode Mode;
212
206
+ extern PGDLLIMPORT ProcessingMode Mode;
213
-
207
+
214
208
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
215
209
#define IsInitProcessingMode() (Mode == InitProcessing)
216
- diff --git a/src/include/storage/checksum.h b/src/include/storage/checksum.h
217
- index 433755e279..de06d3b0cf 100644
218
- --- a/src/include/storage/checksum.h
219
- +++ b/src/include/storage/checksum.h
220
- @@ -14,6 +14,7 @@
221
- #define CHECKSUM_H
222
-
223
- #include "storage/block.h"
224
- + #include "port/pg_crc32c.h"
225
-
226
- /*
227
- * Compute the checksum for a Postgres page. The page must be aligned on a
228
- @@ -21,4 +22,11 @@
229
- */
230
- extern uint16 pg_checksum_page(char *page, BlockNumber blkno);
231
-
232
- + /*
233
- + * Wrapper function for COMP_CRC32C macro. Was added to avoid
234
- + * FRONTEND macro use for pg_comp_crc32c pointer in windows build.
235
- + */
236
- + extern pg_crc32c
237
- + comp_crc32c(pg_crc32c *crc, const void *data, size_t len);
238
- +
239
- #endif /* CHECKSUM_H */
240
- diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h
241
- index a49d27febb..459c938018 100644
242
- --- a/src/include/storage/checksum_impl.h
243
- +++ b/src/include/storage/checksum_impl.h
244
- @@ -213,3 +213,9 @@ pg_checksum_page(char *page, BlockNumber blkno)
245
- */
246
- return (checksum % 65535) + 1;
247
- }
248
- +
249
- + pg_crc32c comp_crc32c(pg_crc32c *crc, const void *data, size_t len)
250
- + {
251
- + COMP_CRC32C(*crc, data, len);
252
- + return *crc;
253
- + }
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
254
228
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
255
- index 4fef3e2107..e55430879c 100644
229
+ index 4fef3e21072..e55430879c3 100644
256
230
--- a/src/include/storage/copydir.h
257
231
+++ b/src/include/storage/copydir.h
258
232
@@ -13,6 +13,9 @@
259
233
#ifndef COPYDIR_H
260
234
#define COPYDIR_H
261
-
235
+
262
236
+ typedef void (*copydir_hook_type) (const char *path);
263
237
+ extern PGDLLIMPORT copydir_hook_type copydir_hook;
264
238
+
265
239
extern void copydir(char *fromdir, char *todir, bool recurse);
266
240
extern void copy_file(char *fromfile, char *tofile);
267
-
241
+
268
242
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
269
- index 0298ed1a2b..24c684771d 100644
243
+ index 0298ed1a2bc..24c684771d0 100644
270
244
--- a/src/include/storage/smgr.h
271
245
+++ b/src/include/storage/smgr.h
272
246
@@ -116,6 +116,17 @@ extern void AtEOXact_SMgr(void);
273
247
/* internals: move me elsewhere -- ay 7/94 */
274
-
248
+
275
249
/* in md.c */
276
250
+
277
251
+ typedef void (*mdextend_hook_type) (RelFileNodeBackend smgr_rnode,
0 commit comments