Skip to content

Commit 0e000fa

Browse files
committed
[PGPRO-5771] Revert changes for stable branches (last 6 commits).
At first we decided to solve this task for master branch only. Tags: ptrack
1 parent 099b0b0 commit 0e000fa

File tree

6 files changed

+252
-358
lines changed

6 files changed

+252
-358
lines changed

engine.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131
#include "access/xlog.h"
3232
#include "catalog/pg_tablespace.h"
3333
#include "miscadmin.h"
34-
#ifdef WIN32
35-
#include "storage/checksum.h"
36-
#else
3734
#include "port/pg_crc32c.h"
38-
#endif
3935
#include "storage/copydir.h"
4036
#if PG_VERSION_NUM >= 120000
4137
#include "storage/md.h"
@@ -77,12 +73,7 @@ ptrack_file_exists(const char *path)
7773
static void
7874
ptrack_write_chunk(int fd, pg_crc32c *crc, char *chunk, size_t size)
7975
{
80-
81-
#ifdef WIN32
82-
comp_crc32c(crc, (char *) chunk, size);
83-
#else
8476
COMP_CRC32C(*crc, (char *) chunk, size);
85-
#endif
8677

8778
if (write(fd, chunk, size) != size)
8879
{
@@ -202,11 +193,7 @@ ptrackMapReadFromFile(const char *ptrack_path)
202193
pg_crc32c *file_crc;
203194

204195
INIT_CRC32C(crc);
205-
#ifdef WIN32
206-
comp_crc32c(&crc, (char *) ptrack_map, PtrackCrcOffset);
207-
#else
208196
COMP_CRC32C(crc, (char *) ptrack_map, PtrackCrcOffset);
209-
#endif
210197
FIN_CRC32C(crc);
211198

212199
file_crc = (pg_crc32c *) ((char *) ptrack_map + PtrackCrcOffset);

patches/REL_11_STABLE-ptrack-core.diff

Lines changed: 56 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
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-
71
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
8-
index 3e53b3df6f..f76bfc2a64 100644
2+
index 3e53b3df6fb..f76bfc2a646 100644
93
--- a/src/backend/replication/basebackup.c
104
+++ b/src/backend/replication/basebackup.c
115
@@ -209,6 +209,13 @@ static const struct exclude_list_item excludeFiles[] =
126
{"postmaster.pid", false},
137
{"postmaster.opts", false},
14-
8+
159
+ /*
1610
+ * Skip all transient ptrack files, but do copy ptrack.map, since it may
1711
+ * be successfully used immediately after backup. TODO: check, test?
@@ -34,13 +28,13 @@ index 3e53b3df6f..f76bfc2a64 100644
3428
{"config_exec_params", true},
3529
#endif
3630
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
3832
--- a/src/backend/storage/file/copydir.c
3933
+++ b/src/backend/storage/file/copydir.c
4034
@@ -27,6 +27,8 @@
4135
#include "miscadmin.h"
4236
#include "pgstat.h"
43-
37+
4438
+copydir_hook_type copydir_hook = NULL;
4539
+
4640
/*
@@ -49,88 +43,88 @@ index 4a0d23b11e..d59009a4c8 100644
4943
@@ -78,6 +80,9 @@ copydir(char *fromdir, char *todir, bool recurse)
5044
}
5145
FreeDir(xldir);
52-
46+
5347
+ if (copydir_hook)
5448
+ copydir_hook(todir);
5549
+
5650
/*
5751
* Be paranoid here and fsync all files to ensure the copy is really done.
5852
* But if fsync is disabled, we're done.
5953
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
6155
--- a/src/backend/storage/smgr/md.c
6256
+++ b/src/backend/storage/smgr/md.c
6357
@@ -39,6 +39,7 @@
6458
#include "utils/memutils.h"
6559
#include "pg_trace.h"
66-
60+
6761
+ProcessSyncRequests_hook_type ProcessSyncRequests_hook = NULL;
68-
62+
6963
/* intervals for calling AbsorbFsyncRequests in mdsync and mdpostckpt */
7064
#define FSYNCS_PER_ABSORB 10
7165
@@ -114,6 +115,8 @@ typedef struct _MdfdVec
72-
66+
7367
static MemoryContext MdCxt; /* context for all MdfdVec objects */
74-
68+
7569
+mdextend_hook_type mdextend_hook = NULL;
7670
+mdwrite_hook_type mdwrite_hook = NULL;
77-
71+
7872
/*
7973
* 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,
8175
register_dirty_segment(reln, forknum, v);
82-
76+
8377
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
8478
+
8579
+ if (mdextend_hook)
8680
+ mdextend_hook(reln->smgr_rnode, forknum, blocknum);
8781
}
88-
82+
8983
/*
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+
9286
if (!skipFsync && !SmgrIsTemp(reln))
9387
register_dirty_segment(reln, forknum, v);
9488
+
9589
+ if (mdwrite_hook)
9690
+ mdwrite_hook(reln->smgr_rnode, forknum, blocknum);
9791
}
98-
92+
9993
/*
100-
@@ -1371,6 +1380,9 @@ mdsync(void)
94+
@@ -1329,6 +1338,9 @@ mdsync(void)
10195
CheckpointStats.ckpt_longest_sync = longest;
10296
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
103-
97+
10498
+ if (ProcessSyncRequests_hook)
10599
+ ProcessSyncRequests_hook();
106100
+
107101
/* Flag successful completion of mdsync */
108102
mdsync_in_progress = false;
109103
}
110104
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
112106
--- a/src/bin/pg_resetwal/pg_resetwal.c
113107
+++ 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);
115109
static void FindEndOfXLOG(void);
116110
static void KillExistingXLOG(void);
117111
static void KillExistingArchiveStatus(void);
118112
+static void KillExistingPtrack(void);
119113
static void WriteEmptyXLOG(void);
120114
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[])
123117
RewriteControlFile();
124118
KillExistingXLOG();
125119
KillExistingArchiveStatus();
126120
+ KillExistingPtrack();
127121
WriteEmptyXLOG();
128-
122+
129123
printf(_("Write-ahead log reset\n"));
130-
@@ -1210,6 +1212,57 @@ KillExistingArchiveStatus(void)
124+
@@ -1201,6 +1203,57 @@ KillExistingArchiveStatus(void)
131125
}
132126
}
133-
127+
134128
+/*
135129
+ * Remove existing ptrack files
136130
+ */
@@ -182,17 +176,17 @@ index 611edf6ade..ec1c1212bd 100644
182176
+ }
183177
+}
184178
+
185-
179+
186180
/*
187181
* Write an empty XLOG file, containing only the checkpoint record
188182
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
190184
--- a/src/bin/pg_rewind/filemap.c
191185
+++ b/src/bin/pg_rewind/filemap.c
192186
@@ -118,6 +118,10 @@ static const struct exclude_list_item excludeFiles[] =
193187
{"postmaster.pid", false},
194188
{"postmaster.opts", false},
195-
189+
196190
+ {"ptrack.map.mmap", false},
197191
+ {"ptrack.map", false},
198192
+ {"ptrack.map.tmp", false},
@@ -201,77 +195,57 @@ index 8ea7fafa27..997168fcac 100644
201195
{NULL, false}
202196
};
203197
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
204-
index 7c9f319b67..1e29827030 100644
198+
index 80241455357..50dca7bf6f4 100644
205199
--- a/src/include/miscadmin.h
206200
+++ b/src/include/miscadmin.h
207-
@@ -379,7 +379,7 @@ typedef enum ProcessingMode
201+
@@ -367,7 +367,7 @@ typedef enum ProcessingMode
208202
NormalProcessing /* normal processing */
209203
} ProcessingMode;
210-
204+
211205
-extern ProcessingMode Mode;
212206
+extern PGDLLIMPORT ProcessingMode Mode;
213-
207+
214208
#define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
215209
#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
254228
diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
255-
index 4fef3e2107..e55430879c 100644
229+
index 4fef3e21072..e55430879c3 100644
256230
--- a/src/include/storage/copydir.h
257231
+++ b/src/include/storage/copydir.h
258232
@@ -13,6 +13,9 @@
259233
#ifndef COPYDIR_H
260234
#define COPYDIR_H
261-
235+
262236
+typedef void (*copydir_hook_type) (const char *path);
263237
+extern PGDLLIMPORT copydir_hook_type copydir_hook;
264238
+
265239
extern void copydir(char *fromdir, char *todir, bool recurse);
266240
extern void copy_file(char *fromfile, char *tofile);
267-
241+
268242
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h
269-
index 0298ed1a2b..24c684771d 100644
243+
index 0298ed1a2bc..24c684771d0 100644
270244
--- a/src/include/storage/smgr.h
271245
+++ b/src/include/storage/smgr.h
272246
@@ -116,6 +116,17 @@ extern void AtEOXact_SMgr(void);
273247
/* internals: move me elsewhere -- ay 7/94 */
274-
248+
275249
/* in md.c */
276250
+
277251
+typedef void (*mdextend_hook_type) (RelFileNodeBackend smgr_rnode,

0 commit comments

Comments
 (0)