forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf88bd31
committed
Don't call palloc() while holding a spinlock, either.
Fix some more violations of the "only straight-line code inside aspinlock" rule. These are hazardous not only because they riskholding the lock for an excessively long time, but because it'spossible for palloc to throw elog(ERROR), leaving a stuck spinlockbehind.copy_replication_slot() had two separate places that did pallocswhile holding a spinlock. We can make the code simpler and saferby copying the whole ReplicationSlot struct into a local variablewhile holding the spinlock, and then referencing that copy.(While that's arguably more cycles than we really need to spendholding the lock, the struct isn't all that big, and this way seemsfar more maintainable than copying fields piecemeal. Anyway thisis surely much cheaper than a palloc.) That bug goes back to v12.InvalidateObsoleteReplicationSlots() not only did a palloc whileholding a spinlock, but for extra sloppiness then leaked the memory--- probably for the lifetime of the checkpointer process, thoughI didn't try to verify that. Fortunately that silliness is newin HEAD.pg_get_replication_slots() had a cosmetic violation of the rule,in that it only assumed it's safe to call namecpy() while holdinga spinlock. Still, that's a hazard waiting to bite somebody, andthere were some other cosmetic coding-rule violations in the samefunction, so clean it up. I back-patched this as far as v10; thecode exists before that but it looks different, and this didn'tseem important enough to adapt the patch further back.Discussion:https://postgr.es/m/20200602.161518.1399689010416646074.horikyota.ntt@gmail.com1 parent4d685f6 commitf88bd31
File tree
3 files changed
+57
-61
lines changed- src
- backend/replication
- include/replication
3 files changed
+57
-61
lines changedLines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1099 | 1099 |
| |
1100 | 1100 |
| |
1101 | 1101 |
| |
1102 |
| - | |
| 1102 | + | |
1103 | 1103 |
| |
1104 | 1104 |
| |
1105 | 1105 |
| |
| |||
1112 | 1112 |
| |
1113 | 1113 |
| |
1114 | 1114 |
| |
1115 |
| - | |
| 1115 | + | |
1116 | 1116 |
| |
1117 | 1117 |
| |
1118 | 1118 |
| |
1119 | 1119 |
| |
1120 | 1120 |
| |
1121 | 1121 |
| |
1122 | 1122 |
| |
1123 |
| - | |
| 1123 | + | |
| 1124 | + | |
1124 | 1125 |
| |
1125 | 1126 |
| |
1126 | 1127 |
| |
1127 | 1128 |
| |
1128 | 1129 |
| |
1129 | 1130 |
| |
1130 | 1131 |
| |
1131 |
| - | |
| 1132 | + | |
1132 | 1133 |
| |
1133 | 1134 |
| |
1134 | 1135 |
| |
| |||
1138 | 1139 |
| |
1139 | 1140 |
| |
1140 | 1141 |
| |
1141 |
| - | |
| 1142 | + | |
1142 | 1143 |
| |
1143 | 1144 |
| |
1144 | 1145 |
| |
|
Lines changed: 49 additions & 54 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
278 | 278 |
| |
279 | 279 |
| |
280 | 280 |
| |
| 281 | + | |
281 | 282 |
| |
282 | 283 |
| |
283 |
| - | |
284 |
| - | |
285 |
| - | |
286 |
| - | |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 | 284 |
| |
294 | 285 |
| |
295 | 286 |
| |
296 | 287 |
| |
297 | 288 |
| |
298 | 289 |
| |
299 | 290 |
| |
| 291 | + | |
300 | 292 |
| |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 |
| - | |
309 |
| - | |
310 |
| - | |
311 |
| - | |
| 293 | + | |
312 | 294 |
| |
313 | 295 |
| |
| 296 | + | |
314 | 297 |
| |
315 | 298 |
| |
316 | 299 |
| |
317 |
| - | |
| 300 | + | |
318 | 301 |
| |
319 |
| - | |
| 302 | + | |
320 | 303 |
| |
321 | 304 |
| |
322 |
| - | |
| 305 | + | |
323 | 306 |
| |
324 |
| - | |
| 307 | + | |
325 | 308 |
| |
326 | 309 |
| |
327 | 310 |
| |
328 | 311 |
| |
329 |
| - | |
| 312 | + | |
330 | 313 |
| |
331 | 314 |
| |
332 |
| - | |
| 315 | + | |
333 | 316 |
| |
334 |
| - | |
335 |
| - | |
| 317 | + | |
| 318 | + | |
336 | 319 |
| |
337 |
| - | |
338 |
| - | |
| 320 | + | |
| 321 | + | |
339 | 322 |
| |
340 | 323 |
| |
341 | 324 |
| |
342 |
| - | |
343 |
| - | |
| 325 | + | |
| 326 | + | |
344 | 327 |
| |
345 | 328 |
| |
346 | 329 |
| |
347 |
| - | |
348 |
| - | |
| 330 | + | |
| 331 | + | |
349 | 332 |
| |
350 | 333 |
| |
351 | 334 |
| |
352 |
| - | |
353 |
| - | |
| 335 | + | |
| 336 | + | |
354 | 337 |
| |
355 | 338 |
| |
356 | 339 |
| |
357 |
| - | |
358 |
| - | |
| 340 | + | |
| 341 | + | |
359 | 342 |
| |
360 | 343 |
| |
361 | 344 |
| |
362 |
| - | |
| 345 | + | |
363 | 346 |
| |
364 | 347 |
| |
365 | 348 |
| |
| |||
378 | 361 |
| |
379 | 362 |
| |
380 | 363 |
| |
| 364 | + | |
| 365 | + | |
| 366 | + | |
381 | 367 |
| |
382 | 368 |
| |
383 | 369 |
| |
| |||
393 | 379 |
| |
394 | 380 |
| |
395 | 381 |
| |
| 382 | + | |
| 383 | + | |
396 | 384 |
| |
397 | 385 |
| |
| 386 | + | |
398 | 387 |
| |
399 | 388 |
| |
400 | 389 |
| |
| |||
653 | 642 |
| |
654 | 643 |
| |
655 | 644 |
| |
| 645 | + | |
| 646 | + | |
656 | 647 |
| |
657 | 648 |
| |
658 | 649 |
| |
| |||
692 | 683 |
| |
693 | 684 |
| |
694 | 685 |
| |
| 686 | + | |
695 | 687 |
| |
696 |
| - | |
697 |
| - | |
698 |
| - | |
699 |
| - | |
| 688 | + | |
700 | 689 |
| |
701 |
| - | |
702 | 690 |
| |
703 | 691 |
| |
704 | 692 |
| |
| |||
711 | 699 |
| |
712 | 700 |
| |
713 | 701 |
| |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
714 | 707 |
| |
715 | 708 |
| |
716 | 709 |
| |
| |||
775 | 768 |
| |
776 | 769 |
| |
777 | 770 |
| |
778 |
| - | |
779 |
| - | |
| 771 | + | |
| 772 | + | |
780 | 773 |
| |
781 |
| - | |
782 |
| - | |
783 |
| - | |
784 |
| - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
785 | 781 |
| |
786 | 782 |
| |
787 |
| - | |
788 |
| - | |
789 |
| - | |
| 783 | + | |
| 784 | + | |
790 | 785 |
| |
791 | 786 |
| |
792 | 787 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 |
| - | |
162 |
| - | |
| 161 | + | |
| 162 | + | |
163 | 163 |
| |
164 | 164 |
| |
165 | 165 |
| |
|
0 commit comments
Comments
(0)