forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit118c9bb
committed
Fix bogus "out of memory" reports in tuplestore.c.
The tuplesort/tuplestore memory management logic assumed that the chunkallocation overhead for its memtuples array could not increase whenincreasing the array size. This is and always was true for tuplesort,but we (I, I think) blindly copied that logic into tuplestore.c withoutnoticing that the assumption failed to hold for the much smaller arrayelements used by tuplestore. Given rather small work_mem, this couldresult in an improper complaint about "unexpected out-of-memory situation",as reported by Brent DeSpain in bug #13530.The easiest way to fix this is just to increase tuplestore's initialarray size so that the assumption holds. Rather than relying on magicconstants, though, let's export a #define from aset.c that representsthe safe allocation threshold, and make tuplestore's calculation dependon that.Do the same in tuplesort.c to keep the logic looking parallel, even thoughtuplesort.c isn't actually at risk at present. This will keep us frombreaking it if we ever muck with the allocation parameters in aset.c.Back-patch to all supported versions. The error message doesn't occurpre-9.3, not so much because the problem can't happen as because thepre-9.3 tuplestore code neglected to check for it. (The chance oftrouble is a great deal larger as of 9.3, though, due to changes in thearray-size-increasing strategy.) However, allowing LACKMEM() to becometrue unexpectedly could still result in less-than-desirable behavior,so let's patch it all the way back.1 parentb58e8ca commit118c9bb
File tree
4 files changed
+42
-15
lines changed- src
- backend/utils
- mmgr
- sort
- include/utils
4 files changed
+42
-15
lines changedLines changed: 8 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
| |||
476 | 476 |
| |
477 | 477 |
| |
478 | 478 |
| |
| 479 | + | |
| 480 | + | |
479 | 481 |
| |
| 482 | + | |
| 483 | + | |
| 484 | + | |
480 | 485 |
| |
481 | 486 |
| |
482 | 487 |
| |
|
Lines changed: 13 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
571 | 571 |
| |
572 | 572 |
| |
573 | 573 |
| |
574 |
| - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
575 | 582 |
| |
576 | 583 |
| |
577 | 584 |
| |
| |||
1064 | 1071 |
| |
1065 | 1072 |
| |
1066 | 1073 |
| |
1067 |
| - | |
1068 |
| - | |
1069 |
| - | |
1070 |
| - | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
1071 | 1078 |
| |
1072 | 1079 |
| |
1073 | 1080 |
| |
| |||
1080 | 1087 |
| |
1081 | 1088 |
| |
1082 | 1089 |
| |
1083 |
| - | |
| 1090 | + | |
1084 | 1091 |
| |
1085 | 1092 |
| |
1086 | 1093 |
| |
|
Lines changed: 13 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
265 | 265 |
| |
266 | 266 |
| |
267 | 267 |
| |
268 |
| - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
269 | 276 |
| |
270 | 277 |
| |
271 | 278 |
| |
| |||
639 | 646 |
| |
640 | 647 |
| |
641 | 648 |
| |
642 |
| - | |
643 |
| - | |
644 |
| - | |
645 |
| - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
646 | 653 |
| |
647 | 654 |
| |
648 | 655 |
| |
| |||
655 | 662 |
| |
656 | 663 |
| |
657 | 664 |
| |
658 |
| - | |
| 665 | + | |
659 | 666 |
| |
660 | 667 |
| |
661 | 668 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
148 | 156 |
|
0 commit comments
Comments
(0)