You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only one configurable option is `ptrack.map_size` (in MB). Default is `-1`, which means `ptrack` is turned off. In order to reduce number of false positives it is recommended to set `ptrack.map_size` to `1 / 1000` of expected `PGDATA` size (i.e. `1000` for a 1 TB database).
60
+
The only one configurable option is `ptrack.map_size` (in MB). Default is `0`, which means `ptrack` is turned off. In order to reduce number of false positives it is recommended to set `ptrack.map_size` to `1 / 1000` of expected `PGDATA` size (i.e. `1000` for a 1 TB database).
61
61
62
62
To disable `ptrack` and clean up all remaining service files set `ptrack.map_size` to `0`.
63
63
@@ -74,7 +74,7 @@ Usage example:
74
74
postgres=# SELECT ptrack_version();
75
75
ptrack_version
76
76
----------------
77
-
2.2
77
+
2.3
78
78
(1 row)
79
79
80
80
postgres=# SELECT ptrack_init_lsn();
@@ -115,27 +115,34 @@ Usually, you have to only install new version of `ptrack` and do `ALTER EXTENSIO
115
115
116
116
Since version 2.2 we use a different algorithm for tracking changed pages. Thus, data recorded in the `ptrack.map` using pre 2.2 versions of `ptrack` is incompatible with newer versions. After extension upgrade and server restart old `ptrack.map` will be discarded with `WARNING` and initialized from the scratch.
117
117
118
+
#### Upgrading from 2.2.* to 2.3.*:
119
+
120
+
* Stop your server
121
+
* Update ptrack binaries
122
+
* Remove global/ptrack.map.mmap if it exist in server data directory
123
+
* Start server
124
+
* Do `ALTER EXTENSION 'ptrack' UPDATE;`.
125
+
118
126
## Limitations
119
127
120
128
1. You can only use `ptrack` safely with `wal_level >= 'replica'`. Otherwise, you can lose tracking of some changes if crash-recovery occurs, since [certain commands are designed not to write WAL at all if wal_level is minimal](https://www.postgresql.org/docs/12/populate.html#POPULATE-PITR), but we only durably flush `ptrack` map at checkpoint time.
121
129
122
130
2. The only one production-ready backup utility, that fully supports `ptrack` is [pg_probackup](https://github.com/postgrespro/pg_probackup).
123
131
124
-
3.Currently, you cannot resize `ptrack` map in runtime, only on postmaster start. Also, you will loose all tracked changes, so it is recommended to do so in the maintainance window and accompany this operation with full backup. See [TODO](#TODO) for details.
132
+
3.You cannot resize `ptrack` map in runtime, only on postmaster start. Also, you will loose all tracked changes, so it is recommended to do so in the maintainance window and accompany this operation with full backup.
125
133
126
-
4. You will need up to `ptrack.map_size * 3` of additional disk space, since `ptrack` uses two additional temporary files for durability purpose. See [Architecture section](#Architecture) for details.
134
+
4. You will need up to `ptrack.map_size * 2` of additional disk space, since `ptrack` uses additional temporary file for durability purpose. See [Architecture section](#Architecture) for details.
127
135
128
136
## Benchmarks
129
137
130
138
Briefly, an overhead of using `ptrack` on TPS usually does not exceed a couple of percent (~1-3%) for a database of dozens to hundreds of gigabytes in size, while the backup time scales down linearly with backup size with a coefficient ~1. It means that an incremental `ptrack` backup of a database with only 20% of changed pages will be 5 times faster than a full backup. More details [here](benchmarks).
131
139
132
140
## Architecture
133
141
134
-
We use a single shared hash table in `ptrack`, which is mapped in memory from the file on disk using `mmap`. Due to the fixed size of the map there may be false positives (when some block is marked as changed without being actually modified), but not false negative results. However, these false postives may be completely eliminated by setting a high enough `ptrack.map_size`.
142
+
We use a single shared hash table in `ptrack`. Due to the fixed size of the map there may be false positives (when some block is marked as changed without being actually modified), but not false negative results. However, these false postives may be completely eliminated by setting a high enough `ptrack.map_size`.
135
143
136
-
All reads/writes are made using atomic operations on `uint64` entries, so the map is completely lockless during the normal PostgreSQL operation. Because we do not use locks for read/write access and cannot control `mmap` eviction back to disk, `ptrack` keeps a map (`ptrack.map`) since the last checkpoint intact and uses up to 2 additional temporary files:
144
+
All reads/writes are made using atomic operations on `uint64` entries, so the map is completely lockless during the normal PostgreSQL operation. Because we do not use locks for read/write access, `ptrack` keeps a map (`ptrack.map`) since the last checkpoint intact and uses up to 1 additional temporary file:
137
145
138
-
* working copy `ptrack.map.mmap` for doing `mmap` on it (there is a [TODO](#TODO) item);
139
146
* temporary file `ptrack.map.tmp` to durably replace `ptrack.map` during checkpoint.
140
147
141
148
Map is written on disk at the end of checkpoint atomically block by block involving the CRC32 checksum calculation that is checked on the next whole map re-read after crash-recovery or restart.
@@ -165,8 +172,6 @@ Available test modes (`MODE`) are `basic` (default) and `paranoia` (per-block ch
165
172
166
173
### TODO
167
174
168
-
* Use POSIX `shm_open()` instead of `open()` to do not create an additional working copy of `ptrack` map file.
169
175
* Should we introduce `ptrack.map_path` to allow `ptrack` service files storage outside of `PGDATA`? Doing that we will avoid patching PostgreSQL binary utilities to ignore `ptrack.map.*` files.
170
176
* Can we resize `ptrack` map on restart but keep the previously tracked changes?
171
-
* Can we resize `ptrack` map dynamicaly?
172
177
* Can we write a formal proof, that we never loose any modified page with `ptrack`? With TLA+?
0 commit comments