aboutsummaryrefslogtreecommitdiff
path: root/src/include/regex/regex.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-10-22 11:54:02 +0900
committerMichael Paquier <michael@paquier.xyz>2022-10-22 11:54:02 +0900
commit6cc66197ff9aa34cc47486d7bf719f376f6f5ff8 (patch)
tree867e8547073a6192942bab9c9a6e618b4c230cf6 /src/include/regex/regex.h
parent1f0c4fa255253d223447c2383ad2b384a6f05854 (diff)
downloadpostgresql-6cc66197ff9aa34cc47486d7bf719f376f6f5ff8.tar.gz
postgresql-6cc66197ff9aa34cc47486d7bf719f376f6f5ff8.zip
Improve memory handling across SQL-callable backup functions
Since pg_backup_start() and pg_backup_stop() exist, the tablespace map data and the backup state data (backup_label string until 7d70809) have been allocated in the TopMemoryContext. This approach would cause memory leaks in the session calling these functions if failures happen before pg_backup_stop() ends, leaking more memory on repeated failures. Both things need little memory so that would not be really noticeable for most users, except perhaps connection poolers with long-lived connections able to trigger backup failures with these functions. This commit improves the logic in this area by not allocating anymore the backup-related data that needs to travel across the SQL-callable backup functions in TopMemoryContext, by using instead a dedicated memory context child of TopMemoryContext. The memory context is created in pg_backup_start() and deleted when finishing pg_backup_stop(). In the event of an in-flight failure, this memory context gets reset in the follow-up pg_backup_start() call, so as we are sure that only one run worth of data is leaked at any time. Some cleanup was already done for the backup data on a follow-up call of pg_backup_start(), but using a memory context makes the whole simpler. BASE_BACKUP commands are executed in isolation, relying on the memory context created for replication commands, hence these do not need such an extra logic. Author: Bharath Rupireddy Reviewed-by: Robert Haas, Alvaro Herrera, Cary Huang, Michael Paquier Discussion: https://postgr.es/m/CALj2ACXqvfKF2B0beQ=aJMdWnpNohmBPsRg=EDQj_6y1t2O8mQ@mail.gmail.com
Diffstat (limited to 'src/include/regex/regex.h')
0 files changed, 0 insertions, 0 deletions