forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6f38c43
committed
Avoid stack overflow in ShowTransactionStateRec()
The function recurses, but didn't perform stack-depth checks. It'sjust a debugging aid, so instead of the usual check_stack_depth()call, stop the printing if we'd risk stack overflow.Here's an example of how to test this: (n=1000000; printf "BEGIN;"; for ((i=1;i<=$n;i++)); do printf "SAVEPOINT s$i;"; done; printf "SET log_min_messages = 'DEBUG5'; SAVEPOINT sp;") | psql >/dev/nullIn the passing, swap building the list of child XIDs and recursing toparent. That saves memory while recursing, reducing the risk of out ofmemory errors with lots of subtransactions. The saving is not verysignificant in practice, but this order seems more logical anyway.Report by Egor Chindyaskin and Alexander Lakhin.Discussion:https://www.postgresql.org/message-id/1672760457.940462079%40f306.i.mail.ruAuthor: Heikki LinnakangasReviewed-by: Robert Haas, Andres Freund, Alexander Korotkov1 parentfefd9a3 commit6f38c43
1 file changed
+15
-6
lines changedLines changed: 15 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5583 | 5583 |
| |
5584 | 5584 |
| |
5585 | 5585 |
| |
5586 |
| - | |
| 5586 | + | |
| 5587 | + | |
| 5588 | + | |
| 5589 | + | |
| 5590 | + | |
| 5591 | + | |
| 5592 | + | |
| 5593 | + | |
| 5594 | + | |
| 5595 | + | |
| 5596 | + | |
| 5597 | + | |
| 5598 | + | |
| 5599 | + | |
5587 | 5600 |
| |
| 5601 | + | |
5588 | 5602 |
| |
5589 | 5603 |
| |
5590 | 5604 |
| |
| |||
5593 | 5607 |
| |
5594 | 5608 |
| |
5595 | 5609 |
| |
5596 |
| - | |
5597 |
| - | |
5598 |
| - | |
5599 |
| - | |
5600 | 5610 |
| |
5601 | 5611 |
| |
5602 | 5612 |
| |
| |||
5608 | 5618 |
| |
5609 | 5619 |
| |
5610 | 5620 |
| |
5611 |
| - | |
5612 | 5621 |
| |
5613 | 5622 |
| |
5614 | 5623 |
| |
|
0 commit comments
Comments
(0)