- Notifications
You must be signed in to change notification settings - Fork28
Commit4ddd8f5
committed
Fix memory leak in TRUNCATE decoding
When decoding a TRUNCATE record, the relids array was being allocated inthe main ReorderBuffer memory context, but not released with the changeresulting in a memory leak.The array was also ignored when serializing/deserializing the change,assuming all the information is stored in the change itself. So whenspilling the change to disk, we've only we have serialized only thepointer to the relids array. Thanks to never releasing the array,the pointer however remained valid even after loading the change backto memory, preventing an actual crash.This fixes both the memory leak and (de)serialization. The relids arrayis still allocated in the main ReorderBuffer memory context (none of theexisting ones seems like a good match, and adding an extra context seemslike an overkill). The allocation is wrapped in a new ReorderBuffer APIfunctions, to keep the details within reorderbuffer.c, just like theother ReorderBufferGet methods do.Author: Tomas VondraDiscussion:https://www.postgresql.org/message-id/flat/66175a41-9342-2845-652f-1bd4c3ee50aa%402ndquadrant.comBackpatch: 11, where decoding of TRUNCATE was introduced1 parentcaa0c6c commit4ddd8f5
File tree
3 files changed
+73
-2
lines changed- src
- backend/replication/logical
- include/replication
3 files changed
+73
-2
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
859 | 859 |
| |
860 | 860 |
| |
861 | 861 |
| |
862 |
| - | |
| 862 | + | |
| 863 | + | |
863 | 864 |
| |
864 | 865 |
| |
865 | 866 |
| |
|
Lines changed: 68 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
409 | 409 |
| |
410 | 410 |
| |
411 | 411 |
| |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
412 | 419 |
| |
413 | 420 |
| |
414 | 421 |
| |
415 |
| - | |
416 | 422 |
| |
417 | 423 |
| |
418 | 424 |
| |
| |||
450 | 456 |
| |
451 | 457 |
| |
452 | 458 |
| |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
453 | 490 |
| |
454 | 491 |
| |
455 | 492 |
| |
| |||
2412 | 2449 |
| |
2413 | 2450 |
| |
2414 | 2451 |
| |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
2415 | 2472 |
| |
2416 | 2473 |
| |
2417 | 2474 |
| |
| |||
2695 | 2752 |
| |
2696 | 2753 |
| |
2697 | 2754 |
| |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
2698 | 2765 |
| |
2699 | 2766 |
| |
2700 | 2767 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
402 | 402 |
| |
403 | 403 |
| |
404 | 404 |
| |
| 405 | + | |
| 406 | + | |
| 407 | + | |
405 | 408 |
| |
406 | 409 |
| |
407 | 410 |
| |
|
0 commit comments
Comments
(0)