Re: Avoid memory leaks during base backups
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Robert Haas <robertmhaas@gmail.com>,
Michael Paquier <michael@paquier.xyz>, Cary Huang <cary.huang@highgo.ca>, pgsql-hackers@lists.postgresql.org
Date: 2022-10-21T06:04:27Z
Lists: pgsql-hackers
Attachments
- v9-0001-Avoid-memory-leaks-during-backups-using-SQL-calla.patch (application/octet-stream) patch v9-0001
On Thu, Oct 20, 2022 at 11:17 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > > On 2022-Oct-20, Bharath Rupireddy wrote: > > > I think elsewhere in the code we reset dangling pointers either ways - > > before or after deleting/resetting memory context. But placing them > > before would give us extra safety in case memory context > > deletion/reset fails. Not sure what's the best way. However, I'm > > nullifying the dangling pointers after deleting/resetting memory > > context. > > I agree that's a good idea, and the patch looks good to me, but I don't > think asserting that they are null afterwards is useful. +1. Removed those assertions. Please see the attached v9 patch. On Fri, Oct 21, 2022 at 12:21 AM Robert Haas <robertmhaas@gmail.com> wrote: > > On Thu, Oct 20, 2022 at 1:35 PM Bharath Rupireddy > <bharath.rupireddyforpostgres@gmail.com> wrote: > > I think elsewhere in the code we reset dangling pointers either ways - > > before or after deleting/resetting memory context. But placing them > > before would give us extra safety in case memory context > > deletion/reset fails. Not sure what's the best way. > > I think it's OK to assume that deallocating memory will always > succeed, so it doesn't matter whether you do it just before or just > after that. But it's not OK to assume that *allocating* memory will > always succeed. Right. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
Commits
-
Improve memory handling across SQL-callable backup functions
- 6cc66197ff9a 16.0 landed