Re: Too many files in pg_replslot folder

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Dmitriy Sarafannikov <d(dot)sarafannikov(at)bk(dot)ru>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Too many files in pg_replslot folder
Date: 2016-03-10 15:34:12
Message-ID: 20160310153412.GA53338@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Dmitriy Sarafannikov wrote:
> Hi, all.
>
> I tried to test logical replication with 'test_decoding' plugin.
> I created logical slot and launched pg_recvlogical utility on ~8 hours.
> When i tried to drop replication slot via pg_drop_replication_slot, backend ate my disk on 100% and didn't want to release him.
> I saw via strace, that he deletes files:
>
> lstat("pg_replslot/test_slot.tmp/xid-2917185562-lsn-4981-AE000000.snap", {st_mode=S_IFREG|0600, st_size=169, ...}) = 0
> unlink("pg_replslot/test_slot.tmp/xid-2917185562-lsn-4981-AE000000.snap") = 0

> He seemed to be in infinite loop. 1109428 files were in the slot folder.
> It looks like abnormal behavior. Why are so many files?
> Maybe i'm doing something wrong? Or maybe it is bug?
> How i can avoid this?

Well, the files are all different in what you reported, so I would say
it's not a loop but a very long sequence.

This can happen if you have a very long transaction while the snapshot
for the slot is being built, and a million other transactions happen
before the long transaction commits. One way in which this would go on
and on until it fills the disk is that you have a prepared transaction
that you forgot about (See select * from pg_prepared_xacts to diagnose
this one). Or you could just have a very long transaction (see select *
from pg_stat_activity).

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-03-10 16:06:36 Re: Performance Improvement in SQL
Previous Message David G. Johnston 2016-03-10 15:13:33 Re: BUG #14012: How to change password in postgreSQL?