forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4d9ceb0
committed
Fix bogus tuple-slot management in logical replication UPDATE handling.
slot_modify_cstrings seriously abused the TupleTableSlot API by relyingon a slot's underlying data to stay valid across ExecClearTuple. Sincethis abuse was also quite undocumented, it's little surprise that thecase got broken during the v12 slot rewrites. As reported in bug #16129from Ondřej Jirman, this could lead to crashes or data corruption whena logical replication subscriber processes a row update. Problems wouldonly arise if the subscriber's table contained columns of pass-by-reftypes that were not being copied from the publisher.Fix by explicitly copying the datum/isnull arrays from the source slotthat the old row was in already. This ends up being about the samething that happened pre-v12, but hopefully in a less opaque andfragile way.We might've caught the problem sooner if there were any test casesdealing with updates involving non-replicated or dropped columns.Now there are.Back-patch to v10 where this code came in. Even though the failuredoes not manifest before v12, IMO this code is too fragile to leaveas-is. In any case we certainly want the additional test coverage.Patch by me; thanks to Tomas Vondra for initial investigation.Discussion:https://postgr.es/m/16129-a0c0f48e71741e5f@postgresql.org1 parent8959a5e commit4d9ceb0
File tree
2 files changed
+70
-17
lines changed- src
- backend/replication/logical
- test/subscription/t
2 files changed
+70
-17
lines changedLines changed: 24 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
363 | 363 |
| |
364 | 364 |
| |
365 | 365 |
| |
366 |
| - | |
| 366 | + | |
367 | 367 |
| |
368 |
| - | |
369 |
| - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
370 | 375 |
| |
371 | 376 |
| |
372 |
| - | |
| 377 | + | |
| 378 | + | |
373 | 379 |
| |
374 | 380 |
| |
375 | 381 |
| |
376 | 382 |
| |
377 | 383 |
| |
378 | 384 |
| |
379 | 385 |
| |
380 |
| - | |
| 386 | + | |
381 | 387 |
| |
382 | 388 |
| |
383 |
| - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
384 | 399 |
| |
385 | 400 |
| |
386 | 401 |
| |
| |||
428 | 443 |
| |
429 | 444 |
| |
430 | 445 |
| |
| 446 | + | |
431 | 447 |
| |
432 | 448 |
| |
433 | 449 |
| |
| |||
740 | 756 |
| |
741 | 757 |
| |
742 | 758 |
| |
743 |
| - | |
744 |
| - | |
| 759 | + | |
| 760 | + | |
745 | 761 |
| |
746 | 762 |
| |
747 | 763 |
| |
|
Lines changed: 46 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
| 6 | + | |
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
| 31 | + | |
32 | 32 |
| |
33 |
| - | |
| 33 | + | |
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
| 48 | + | |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
94 | 95 |
| |
95 | 96 |
| |
96 | 97 |
| |
97 |
| - | |
| 98 | + | |
98 | 99 |
| |
99 | 100 |
| |
100 | 101 |
| |
| |||
112 | 113 |
| |
113 | 114 |
| |
114 | 115 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
| |||
139 | 139 |
| |
140 | 140 |
| |
141 | 141 |
| |
| 142 | + | |
142 | 143 |
| |
143 | 144 |
| |
144 | 145 |
| |
145 | 146 |
| |
146 | 147 |
| |
| 148 | + | |
| 149 | + | |
147 | 150 |
| |
148 | 151 |
| |
149 | 152 |
| |
| |||
159 | 162 |
| |
160 | 163 |
| |
161 | 164 |
| |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
162 | 199 |
| |
163 | 200 |
| |
164 | 201 |
| |
|
0 commit comments
Comments
(0)