Skip to content

Commit 3a277bf

Browse files
committed
Make everything applicable on the top of REL_12_STABLE
1 parent f1352d7 commit 3a277bf

File tree

2 files changed

+46
-40
lines changed

2 files changed

+46
-40
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,33 @@ Ptrack is a fast block-level incremental backup engine for PostgreSQL. Currently
66

77
## Installation
88

9-
1) Apply PostgreSQL core patch:
9+
1) Get latest PostgreSQL sources:
1010

1111
```shell
12-
git apply patches/ptrack-2.0-core.diff
12+
git clone https://github.com/postgres/postgres.git -b REL_12_STABLE && cd postgres
1313
```
1414

15-
2) Compile and install PostgreSQL
15+
2) Apply PostgreSQL core patch:
1616

17-
3) Set `ptrack_map_size` (in MB)
17+
```shell
18+
git apply ptrack/patches/ptrack-2.0-core.diff
19+
```
20+
21+
3) Compile and install PostgreSQL
22+
23+
4) Set `ptrack_map_size` (in MB)
1824

1925
```shell
2026
echo 'ptrack_map_size = 64' >> postgres_data/postgresql.conf
2127
```
2228

23-
4) Compile and install `ptrack` extension
29+
5) Compile and install `ptrack` extension
2430

2531
```shell
2632
USE_PGXS=1 make -C /path/to/ptrack/ install
2733
```
2834

29-
5) Run PostgreSQL and create `ptrack` extension
35+
6) Run PostgreSQL and create `ptrack` extension
3036

3137
```sql
3238
CREATE EXTENSION ptrack;

patches/ptrack-2.0-core.diff

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
2-
index 367c30adb01..7ab806622fb 100644
2+
index 863f89f19d2..8f3143758ab 100644
33
--- a/src/backend/commands/dbcommands.c
44
+++ b/src/backend/commands/dbcommands.c
5-
@@ -57,6 +57,7 @@
6-
#include "storage/lmgr.h"
5+
@@ -56,6 +56,7 @@
6+
#include "storage/ipc.h"
77
#include "storage/md.h"
88
#include "storage/procarray.h"
99
+#include "storage/ptrack.h"
1010
#include "storage/smgr.h"
1111
#include "utils/acl.h"
1212
#include "utils/builtins.h"
13-
@@ -659,6 +660,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
13+
@@ -638,6 +639,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
1414
* We don't need to copy subdirectories
1515
*/
1616
copydir(srcpath, dstpath, false);
1717
+ ptrack_walkdir(dstpath, dboid, dsttablespace);
1818

1919
/* Record the filesystem change in XLOG */
2020
{
21-
@@ -1305,6 +1307,7 @@ movedb(const char *dbname, const char *tblspcname)
21+
@@ -1276,6 +1278,7 @@ movedb(const char *dbname, const char *tblspcname)
2222
* Copy files from the old tablespace to the new one
2323
*/
2424
copydir(src_dbpath, dst_dbpath, false);
2525
+ ptrack_walkdir(dst_dbpath, db_id, dst_tblspcoid);
2626

2727
/*
2828
* Record the filesystem change in XLOG
29-
@@ -2216,6 +2219,7 @@ dbase_redo(XLogReaderState *record)
29+
@@ -2139,6 +2142,7 @@ dbase_redo(XLogReaderState *record)
3030
* We don't need to copy subdirectories
3131
*/
3232
copydir(src_path, dst_path, false);
@@ -35,7 +35,7 @@ index 367c30adb01..7ab806622fb 100644
3535
else if (info == XLOG_DBASE_DROP)
3636
{
3737
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
38-
index 1423e6cd1f8..1c8de70c275 100644
38+
index a73893237a4..2a2e17fb33e 100644
3939
--- a/src/backend/replication/basebackup.c
4040
+++ b/src/backend/replication/basebackup.c
4141
@@ -36,6 +36,7 @@
@@ -46,7 +46,7 @@ index 1423e6cd1f8..1c8de70c275 100644
4646
#include "storage/reinit.h"
4747
#include "utils/builtins.h"
4848
#include "utils/ps_status.h"
49-
@@ -193,6 +194,10 @@ static const char *const excludeFiles[] =
49+
@@ -195,6 +196,10 @@ static const char *excludeFiles[] =
5050
"postmaster.pid",
5151
"postmaster.opts",
5252

@@ -58,10 +58,10 @@ index 1423e6cd1f8..1c8de70c275 100644
5858
NULL
5959
};
6060
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
61-
index aba39604811..be265e51c1c 100644
61+
index 7332e6b5903..08693933e18 100644
6262
--- a/src/backend/storage/buffer/bufmgr.c
6363
+++ b/src/backend/storage/buffer/bufmgr.c
64-
@@ -689,7 +689,8 @@ ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum,
64+
@@ -688,7 +688,8 @@ ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum,
6565

6666
SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
6767

@@ -72,31 +72,30 @@ index aba39604811..be265e51c1c 100644
7272
return ReadBuffer_common(smgr, RELPERSISTENCE_PERMANENT, forkNum, blockNum,
7373
mode, strategy, &hit);
7474
diff --git a/src/backend/storage/smgr/Makefile b/src/backend/storage/smgr/Makefile
75-
index 596b564656f..56cb1df7fb4 100644
75+
index e486b7c0d1c..3c8f15b1444 100644
7676
--- a/src/backend/storage/smgr/Makefile
7777
+++ b/src/backend/storage/smgr/Makefile
78-
@@ -14,6 +14,7 @@ include $(top_builddir)/src/Makefile.global
78+
@@ -12,6 +12,6 @@ subdir = src/backend/storage/smgr
79+
top_builddir = ../../../..
80+
include $(top_builddir)/src/Makefile.global
7981

80-
OBJS = \
81-
md.o \
82-
- smgr.o
83-
+ smgr.o \
84-
+ ptrack.o
82+
-OBJS = md.o smgr.o
83+
+OBJS = md.o smgr.o ptrack.o
8584

8685
include $(top_srcdir)/src/backend/common.mk
8786
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
88-
index 85b71154006..b43fd32a549 100644
87+
index 050cee5f9a9..94a7a1f7a1c 100644
8988
--- a/src/backend/storage/smgr/md.c
9089
+++ b/src/backend/storage/smgr/md.c
91-
@@ -35,6 +35,7 @@
92-
#include "storage/bufmgr.h"
90+
@@ -33,6 +33,7 @@
9391
#include "storage/fd.h"
92+
#include "storage/bufmgr.h"
9493
#include "storage/md.h"
9594
+#include "storage/ptrack.h"
9695
#include "storage/relfilenode.h"
9796
#include "storage/smgr.h"
9897
#include "storage/sync.h"
99-
@@ -436,6 +437,8 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
98+
@@ -422,6 +423,8 @@ mdextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
10099
register_dirty_segment(reln, forknum, v);
101100

102101
Assert(_mdnblocks(reln, forknum, v) <= ((BlockNumber) RELSEG_SIZE));
@@ -105,7 +104,7 @@ index 85b71154006..b43fd32a549 100644
105104
}
106105

107106
/*
108-
@@ -717,6 +720,8 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
107+
@@ -692,6 +695,8 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
109108

110109
if (!skipFsync && !SmgrIsTemp(reln))
111110
register_dirty_segment(reln, forknum, v);
@@ -116,7 +115,7 @@ index 85b71154006..b43fd32a549 100644
116115
/*
117116
diff --git a/src/backend/storage/smgr/ptrack.c b/src/backend/storage/smgr/ptrack.c
118117
new file mode 100644
119-
index 00000000000..d3b75dfcc21
118+
index 00000000000..b4e731cf652
120119
--- /dev/null
121120
+++ b/src/backend/storage/smgr/ptrack.c
122121
@@ -0,0 +1,655 @@
@@ -776,7 +775,7 @@ index 00000000000..d3b75dfcc21
776775
+ }
777776
+}
778777
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
779-
index 9cb7c650331..0d5840f09e1 100644
778+
index 705f229b27f..87c5d4f965d 100644
780779
--- a/src/backend/storage/sync/sync.c
781780
+++ b/src/backend/storage/sync/sync.c
782781
@@ -28,6 +28,7 @@
@@ -785,8 +784,8 @@ index 9cb7c650331..0d5840f09e1 100644
785784
#include "storage/md.h"
786785
+#include "storage/ptrack.h"
787786
#include "utils/hsearch.h"
788-
#include "utils/inval.h"
789787
#include "utils/memutils.h"
788+
#include "utils/inval.h"
790789
@@ -418,6 +419,13 @@ ProcessSyncRequests(void)
791790
CheckpointStats.ckpt_longest_sync = longest;
792791
CheckpointStats.ckpt_agg_sync_time = total_elapsed;
@@ -802,26 +801,27 @@ index 9cb7c650331..0d5840f09e1 100644
802801
sync_in_progress = false;
803802
}
804803
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
805-
index 62285792eca..a746dd03b51 100644
804+
index dc8f910ea46..74bda8275cd 100644
806805
--- a/src/backend/utils/misc/guc.c
807806
+++ b/src/backend/utils/misc/guc.c
808-
@@ -78,6 +78,7 @@
807+
@@ -78,6 +78,8 @@
809808
#include "storage/pg_shmem.h"
810-
#include "storage/predicate.h"
811809
#include "storage/proc.h"
810+
#include "storage/predicate.h"
812811
+#include "storage/ptrack.h"
813-
#include "storage/standby.h"
812+
+#include "storage/standby.h"
814813
#include "tcop/tcopprot.h"
815814
#include "tsearch/ts_cache.h"
816-
@@ -589,6 +590,7 @@ static char *recovery_target_xid_string;
815+
#include "utils/builtins.h"
816+
@@ -581,6 +583,7 @@ static char *recovery_target_xid_string;
817817
static char *recovery_target_name_string;
818818
static char *recovery_target_lsn_string;
819819

820820
+static int ptrack_map_size_tmp;
821821

822822
/* should be static, but commands/variable.c needs to get at this */
823823
char *role_string;
824-
@@ -1978,6 +1980,16 @@ static struct config_bool ConfigureNamesBool[] =
824+
@@ -1961,6 +1964,16 @@ static struct config_bool ConfigureNamesBool[] =
825825

826826
static struct config_int ConfigureNamesInt[] =
827827
{
@@ -839,10 +839,10 @@ index 62285792eca..a746dd03b51 100644
839839
{"archive_timeout", PGC_SIGHUP, WAL_ARCHIVING,
840840
gettext_noop("Forces a switch to the next WAL file if a "
841841
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
842-
index fd14844eecf..e735932db8a 100644
842+
index 601f7e9690e..f8bb8ff521f 100644
843843
--- a/src/bin/pg_rewind/filemap.c
844844
+++ b/src/bin/pg_rewind/filemap.c
845-
@@ -102,6 +102,9 @@ static const char *excludeFiles[] =
845+
@@ -103,6 +103,9 @@ static const char *excludeFiles[] =
846846
"postmaster.pid",
847847
"postmaster.opts",
848848

@@ -854,7 +854,7 @@ index fd14844eecf..e735932db8a 100644
854854
};
855855
diff --git a/src/include/storage/ptrack.h b/src/include/storage/ptrack.h
856856
new file mode 100644
857-
index 00000000000..3dd504f1375
857+
index 00000000000..67c66913479
858858
--- /dev/null
859859
+++ b/src/include/storage/ptrack.h
860860
@@ -0,0 +1,129 @@

0 commit comments

Comments
 (0)