Re: Memory context can be its own parent and child in replication command
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-12T09:13:06Z
Lists: pgsql-hackers
Attachments
- v02-0001-Add-additional-memory-context-checks.patch (application/octet-stream)
- v02-0002-Avoid-using-deleted-context-with-replication-com.patch (application/octet-stream)
I've updated the patch with another approach: 0001: This sets the MemoryContext type to T_Invalid just before adding it to the aset freelist, allowing to distinguish between a MemoryContext that was placed in the freelist and shouldn't be used, and a valid one. The existing MemoryContextIsValid checks will be triggered if a MemoryContext in the freelist is used. I've also added additional MemoryContextIsValid to make sure the MemoryContext restored by a transaction is valid. 0002: Keep the replication command alive when there's an ongoing snapshot export. This way, the context restored is valid and can be reused. This requires the replication command context to be created under the TopMemoryContext. Regards, Anthonin Bonnefoy