Skip to content

Commit 247065d

Browse files
author
digoal
committed
fix
1 parent 7f46e7c commit 247065d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

202406/20240621_01.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,34 @@ lsof -p 7,$(pgrep -P 7 | tr '\n' ',')
207207
最后, D-Smart也提供了工具清理孤儿文件, 参考:
208208
- https://www.modb.pro/db/1737302971619303424
209209

210+
以及pg_orphaned插件, 也支持清理孤儿文件:
211+
- https://github.com/bdrouvot/pg_orphaned
212+
213+
这个插件支持事务中的文件不会被查出来当成孤儿文件, 例如:
214+
```
215+
Session 1:
216+
217+
postgres=# begin;
218+
BEGIN
219+
postgres=*# create table bdtinpgro (a int);
220+
CREATE TABLE
221+
222+
Session 2 would report a false orphaned file if using a query like:
223+
224+
postgres=# select * from pg_ls_dir ( '/home/postgres/pgorph/pg_installed/data/base/13580' ) as file where file ~ '^[0-9]*$' and file::text not in (select oid::text from pg_class );
225+
file
226+
-------
227+
16408
228+
(1 row)
229+
230+
while the extension would not report this false positive:
231+
232+
postgres=# select * from pg_list_orphaned();
233+
dbname | path | name | size | mod_time | relfilenode | reloid
234+
--------+------+------+------+----------+-------------+--------
235+
(0 rows)
236+
```
237+
210238
再次提醒: 删除数据文件一定要谨慎.
211239

212240
本文实验可以在我提供的两个docker image中完成:

0 commit comments

Comments
 (0)