forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit06dbd61
committed
pgstat: Prevent stats reset from corrupting slotname by removing slotname
Previously PgStat_StatReplSlotEntry contained the slotname, which was mainlyused when writing out the stats during shutdown, to identify the slot in theserialized data (at runtime the index in ReplicationSlotCtl->replication_slotsis used, but that can change during a restart). Unfortunately the slotname wasoverwritten when the slot's stats were reset.That turned out to only cause "real" problems if the slot was active duringthe reset, triggering an assertion failure at the nextpgstat_report_replslot(). In other paths the stats were re-initialized duringpgstat_acquire_replslot().Fix this by removing slotname from PgStat_StatReplSlotEntry. Instead we canget the slot's name from the slot itself. Besides fixing a bug, this also isarchitecturally cleaner (a name is not really statistics). This is safebecause stats, for a slot removed while shut down, will not be restored atstartup.In 15 the slotname is not removed, but renamed, to avoid changing the statsformat. In master, bump PGSTAT_FILE_FORMAT_ID.This commit does not contain a test for the fix. I think this can only betested by a tap test starting pg_recvlogical in the background and checkingpg_recvlogical's output. That type of test is notoriously hard to be reliable,so committing it shortly before the release is wrapped seems like a bad idea.Reported-by: Jaime Casanova <jcasanov@systemguards.com.ec>Author: Andres Freund <andres@anarazel.de>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>Discussion:https://postgr.es/m/YxfagaTXUNa9ggLb@ahch-toBackpatch: 15-, where the bug was introduced in5891c7a1 parente4c61be commit06dbd61
File tree
6 files changed
+60
-35
lines changed- src
- backend
- replication
- utils/activity
- include
- replication
- utils
6 files changed
+60
-35
lines changedLines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
412 | 412 |
| |
413 | 413 |
| |
414 | 414 |
| |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
415 | 443 |
| |
416 | 444 |
| |
417 | 445 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1367 | 1367 |
| |
1368 | 1368 |
| |
1369 | 1369 |
| |
1370 |
| - | |
| 1370 | + | |
1371 | 1371 |
| |
1372 | 1372 |
| |
1373 | 1373 |
| |
|
Lines changed: 26 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 |
| |
73 | 77 |
| |
74 | 78 |
| |
| |||
82 | 86 |
| |
83 | 87 |
| |
84 | 88 |
| |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - | |
91 | 89 |
| |
92 | 90 |
| |
93 | 91 |
| |
| |||
124 | 122 |
| |
125 | 123 |
| |
126 | 124 |
| |
127 |
| - | |
128 | 125 |
| |
129 | 126 |
| |
130 | 127 |
| |
131 | 128 |
| |
132 | 129 |
| |
133 | 130 |
| |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
134 | 142 |
| |
135 | 143 |
| |
136 | 144 |
| |
137 | 145 |
| |
138 |
| - | |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 |
| - | |
| 146 | + | |
| 147 | + | |
159 | 148 |
| |
160 | 149 |
| |
161 | 150 |
| |
| |||
185 | 174 |
| |
186 | 175 |
| |
187 | 176 |
| |
188 |
| - | |
| 177 | + | |
189 | 178 |
| |
190 |
| - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
191 | 187 |
| |
192 | 188 |
| |
193 | 189 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
242 | 242 |
| |
243 | 243 |
| |
244 | 244 |
| |
245 |
| - | |
| 245 | + | |
246 | 246 |
| |
247 | 247 |
| |
248 | 248 |
| |
| |||
321 | 321 |
| |
322 | 322 |
| |
323 | 323 |
| |
324 |
| - | |
325 | 324 |
| |
326 | 325 |
| |
327 | 326 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
218 | 218 |
| |
219 | 219 |
| |
220 | 220 |
| |
| 221 | + | |
221 | 222 |
| |
222 | 223 |
| |
223 | 224 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
242 | 242 |
| |
243 | 243 |
| |
244 | 244 |
| |
245 |
| - | |
| 245 | + | |
| 246 | + | |
246 | 247 |
| |
247 | 248 |
| |
248 | 249 |
| |
| |||
567 | 568 |
| |
568 | 569 |
| |
569 | 570 |
| |
570 |
| - | |
| 571 | + | |
571 | 572 |
| |
572 | 573 |
| |
573 | 574 |
| |
|
0 commit comments
Comments
(0)