作者
digoal
日期
2021-05-19
标签
PostgreSQL , remove_temp_files_after_crash
背景
V 14以前, 多次backend crash restart后, 数据库可能膨胀, 原因是使用的临时文件不会被清理.
PG 14增加一个参数remove_temp_files_after_crash, 默认为ON, 在crash restart时自动清理临时文件. 避免膨胀.
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=cd91de0d17952b5763466cfa663e98318f26d357
```
Remove temporary files after backend crash
author Tomas Vondra tomas.vondra@postgresql.org
Thu, 18 Mar 2021 15:05:03 +0000 (16:05 +0100)
committer Tomas Vondra tomas.vondra@postgresql.org
Thu, 18 Mar 2021 16:38:28 +0000 (17:38 +0100)
commit cd91de0d17952b5763466cfa663e98318f26d357
tree d0e543e40dc62b32ccf4cbb34cbe3bb77f2ba78d tree
parent da18d829c28197efb04805a43f129f62650e50c8 commit | diff
Remove temporary files after backend crash
After a crash of a backend using temporary files, the files used to be
left behind, on the basis that it might be useful for debugging. But we
don't have any reports of anyone actually doing that, and it means the
disk usage may grow over time due to repeated backend failures (possibly
even hitting ENOSPC). So this behavior is a bit unfortunate, and fixing
it required either manual cleanup (deleting files, which is error-prone)
or restart of the instance (i.e. service disruption).
This implements automatic cleanup of temporary files, controled by a new
GUC remove_temp_files_after_crash. By default the files are removed, but
it can be disabled to restore the old behavior if needed.
Author: Euler Taveira
Reviewed-by: Tomas Vondra, Michael Paquier, Anastasia Lubennikova, Thomas Munro
Discussion: https://postgr.es/m/CAH503wDKdYzyq7U-QJqGn%3DGm6XmoK%2B6_6xTJ-Yn5WSvoHLY1Ww%40mail.gmail.com
```
+ <varlistentry id="guc-remove-temp-files-after-crash" xreflabel="remove_temp_files_after_crash">
+ <term><varname>remove_temp_files_after_crash</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>remove_temp_files_after_crash</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ When set to <literal>on</literal>, which is the default,
+ <productname>PostgreSQL</productname> will automatically remove
+ temporary files after a backend crash. If disabled, the files will be
+ retained and may be used for debugging, for example. Repeated crashes
+ may however result in accumulation of useless files.
+ </para>
+ </listitem>
+ </varlistentry>
+
PostgreSQL 许愿链接
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.
9.9元购买3个月阿里云RDS PostgreSQL实例
PostgreSQL 解决方案集合
德哥 / digoal's github - 公益是一辈子的事.





