forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commit1d5edff
committed
Repair memory leakage while ANALYZE-ing complex index expressions.
The general design of memory management in Postgres is that intermediateresults computed by an expression are not freed until the end of the tuplecycle. For expression indexes, ANALYZE has to re-evaluate each expressionfor each of its sample rows, and it wasn't bothering to free intermediateresults until the end of processing of that index. This could lead to verysubstantial leakage if the intermediate results were large, as in a recentexample from Jakub Ouhrabka. Fix by doing ResetExprContext for each samplerow. This necessitates adding a datumCopy step to ensure that the finalexpression value isn't recycled too. Some quick testing suggests that thischange adds at worst about 10% to the time needed to analyze a table withan expression index; which is annoying, but seems a tolerable price to payto avoid unexpected out-of-memory problems.Back-patch to all supported branches.1 parent17b38fa commit1d5edff
1 file changed
+20
-3
lines changedLines changed: 20 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
529 | 529 |
| |
530 | 530 |
| |
531 | 531 |
| |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
532 | 538 |
| |
533 | 539 |
| |
534 | 540 |
| |
| |||
553 | 559 |
| |
554 | 560 |
| |
555 | 561 |
| |
556 |
| - | |
| 562 | + | |
| 563 | + | |
557 | 564 |
| |
558 | 565 |
| |
559 | 566 |
| |
560 | 567 |
| |
561 | 568 |
| |
562 | 569 |
| |
563 |
| - | |
564 |
| - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
565 | 582 |
| |
566 | 583 |
| |
567 | 584 |
| |
|
0 commit comments
Comments
(0)