pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedVacuum not deleting tuples when lockless
5+ messages / 3 participants
[nested] [flat]
* Vacuum not deleting tuples when lockless
@ 2018-09-14 23:15 Martín Fernández <fmartin91@gmail.com>
2018-09-15 01:52 ` Re: Vacuum not deleting tuples when lockless Jerry Sievers <gsievers19@comcast.net>
2018-09-15 02:17 ` Re: Vacuum not deleting tuples when lockless Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 5+ messages in thread
From: Martín Fernández @ 2018-09-14 23:15 UTC (permalink / raw)
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Hello,
We are experiencing some `vacuum` issues with a given table (potentially more). When a manual vacuum runs on the given table it seems that the `vacuum` process is not doing the expected cleanup.
```
DETAIL: 113257 dead row versions cannot be removed yet.
```
I've been investigating the reasons for vacuum not being able to do it's work and I found that generally the problem is caused by open transactions referencing the dead tuples. I also found that locking can be a problem as well.
I did check that no long running transaction was happening and no locking was happening before running `vacuum` on the given table.
I used this query to check the locks:
```
SELECT query, state,locktype,mode
FROM pg_locks
JOIN pg_stat_activity
USING (pid)
WHERE relation::regclass = 'my_table'::regclass
AND granted IS TRUE;
```
I'm not sure where else to look for a potential issue that could be causing this problem. A few days back we had to use re_pack on the given table to solve our performance issues.
Important thing to clarify is that we are using postgresql 9.2.24
Thanks in advance!
Best,
Martín
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Vacuum not deleting tuples when lockless
2018-09-14 23:15 Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
@ 2018-09-15 01:52 ` Jerry Sievers <gsievers19@comcast.net>
1 sibling, 0 replies; 5+ messages in thread
From: Jerry Sievers @ 2018-09-15 01:52 UTC (permalink / raw)
To: Martín Fernández <fmartin91@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Martín Fernández <fmartin91@gmail.com> writes:
> *
> Hello,
>
> We are experiencing some `vacuum` issues with a given table
> (potentially more). When a manual vacuum runs on the given table it
> seems that the `vacuum` process is not doing the expected cleanup.
>
> ```
> DETAIL: 113257 dead row versions cannot be removed yet.
> ```
>
> I've been investigating the reasons for vacuum not being able to do
> it's work and I found that generally the problem is caused by open
> transactions referencing the dead tuples. I also found that locking
> can be a problem as well.
>
> I did check that no long running transaction was happening and no
> locking was happening before running `vacuum` on the given table.
>
> I used this query to check the locks:
>
> ```
> SELECT query, state,locktype,mode
> FROM pg_locks
> JOIN pg_stat_activity
> USING (pid)
> WHERE relation::regclass = 'my_table'::regclass
> AND granted IS TRUE;
> ```
>
> I'm not sure where else to look for a potential issue that could be
> causing this problem. A few days back we had to use re_pack on the
Also check for...
* Old open prepared xacts.
* Inactive replication slots.
* Standbys confi'd with large vacuum clean up delay and feedback
enabled.
HTH
> given table to solve our performance issues.
>
> Important thing to clarify is that we are using postgresql 9.2.24
>
> Thanks in advance!
>
> Best,
> Martín
>
>
--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 312.241.7800
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Vacuum not deleting tuples when lockless
2018-09-14 23:15 Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
@ 2018-09-15 02:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-09-15 02:29 ` Re: Vacuum not deleting tuples when lockless Jerry Sievers <gsievers19@comcast.net>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2018-09-15 02:17 UTC (permalink / raw)
To: Martín Fernández <fmartin91@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
=?UTF-8?q?Mart=C3=ADn_Fern=C3=A1ndez?= <fmartin91@gmail.com> writes:
> We are experiencing some `vacuum` issues with a given table (potentially more). When a manual vacuum runs on the given table it seems that the `vacuum` process is not doing the expected cleanup.
> DETAIL: 113257 dead row versions cannot be removed yet.
Locks don't really have anything to do with that: what does matter is
how old is the oldest open transaction, because that determines the
"event horizon" that dead row versions have to fall below before they
can be removed. That oldest transaction might not be holding any locks
at the moment, but it doesn't matter, because in principle it could ask
to read this table later --- and it should see the table's contents as
of its snapshot.
Serializable transactions are worse than repeatable-read transactions
for this purpose, because the former will keep a snapshot as of their
start time.
As Jerry mentioned, replication slots can also act like open transactions
for this purpose, though I don't recall how much of that behavior is
present in 9.2.x.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Vacuum not deleting tuples when lockless
2018-09-14 23:15 Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
2018-09-15 02:17 ` Re: Vacuum not deleting tuples when lockless Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-09-15 02:29 ` Jerry Sievers <gsievers19@comcast.net>
2018-09-15 21:33 ` Re: Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Jerry Sievers @ 2018-09-15 02:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Martín Fernández <fmartin91@gmail.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Tom Lane <tgl@sss.pgh.pa.us> writes:
> =?UTF-8?q?Mart=C3=ADn_Fern=C3=A1ndez?= <fmartin91@gmail.com> writes:
>
>> We are experiencing some `vacuum` issues with a given table
>> (potentially more). When a manual vacuum runs on the given table it
>> seems that the `vacuum` process is not doing the expected cleanup.
>
>> DETAIL: 113257 dead row versions cannot be removed yet.
>
> Locks don't really have anything to do with that: what does matter is
> how old is the oldest open transaction, because that determines the
> "event horizon" that dead row versions have to fall below before they
> can be removed. That oldest transaction might not be holding any locks
> at the moment, but it doesn't matter, because in principle it could ask
> to read this table later --- and it should see the table's contents as
> of its snapshot.
>
> Serializable transactions are worse than repeatable-read transactions
> for this purpose, because the former will keep a snapshot as of their
> start time.
>
> As Jerry mentioned, replication slots can also act like open transactions
> for this purpose, though I don't recall how much of that behavior is
> present in 9.2.x.
Oops, didn't notice OP was on 9.2! Presume none, since I don't think we
got rep slots till 9.4 :-)
>
> regards, tom lane
>
>
--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 312.241.7800
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Vacuum not deleting tuples when lockless
2018-09-14 23:15 Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
2018-09-15 02:17 ` Re: Vacuum not deleting tuples when lockless Tom Lane <tgl@sss.pgh.pa.us>
2018-09-15 02:29 ` Re: Vacuum not deleting tuples when lockless Jerry Sievers <gsievers19@comcast.net>
@ 2018-09-15 21:33 ` Martín Fernández <fmartin91@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Martín Fernández @ 2018-09-15 21:33 UTC (permalink / raw)
To: Jerry Sievers <gsievers19@comcast.net>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Tom & Jerry,
Thanks a lot for information!
On Monday (weekends don't have the same load patterns compared to business days) I will take a look at ` pg_prepared_xacts` that seems to expose Jerry's suggestion on xacts. Replication slots don't apply to 9.2.X from what I could investigate so I will discard that suggestion.
Feedback setting (hot_standby_feedback) is turned off in all our replicas, this shouldn't be an issue from what I understood.
Delay setting (vacuum_defer_cleanup_age ) in our master is configured to 0, , this shouldn't be an issue from what I understood.
Thanks a lot!
Best,
Martín
On Fri, Sep 14th, 2018 at 11:29 PM, Jerry Sievers <gsievers19@comcast.net> wrote:
>
>
>
> Tom Lane < tgl@sss.pgh.pa.us > writes:
>
> > =?UTF-8?q?Mart=C3=ADn_Fern=C3=A1ndez?= < fmartin91@gmail.com > writes:
> >
> >> We are experiencing some `vacuum` issues with a given table
> >> (potentially more). When a manual vacuum runs on the given table it
> >> seems that the `vacuum` process is not doing the expected cleanup.
> >
> >> DETAIL: 113257 dead row versions cannot be removed yet.
> >
> > Locks don't really have anything to do with that: what does matter is
> > how old is the oldest open transaction, because that determines the
> > "event horizon" that dead row versions have to fall below before they
> > can be removed. That oldest transaction might not be holding any locks
> > at the moment, but it doesn't matter, because in principle it could ask
> > to read this table later --- and it should see the table's contents as
> > of its snapshot.
> >
> > Serializable transactions are worse than repeatable-read transactions
> > for this purpose, because the former will keep a snapshot as of their
> > start time.
> >
> > As Jerry mentioned, replication slots can also act like open
> transactions
> > for this purpose, though I don't recall how much of that behavior is
> > present in 9.2.x.
>
> Oops, didn't notice OP was on 9.2! Presume none, since I don't think we
> got rep slots till 9.4 :-)
>
> >
> > regards, tom lane
> >
> >
>
> --
> Jerry Sievers
> Postgres DBA/Development Consulting
> e: postgres.consulting@comcast.net
> p: 312.241.7800
>
>
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-09-15 21:33 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 23:15 Vacuum not deleting tuples when lockless Martín Fernández <fmartin91@gmail.com>
2018-09-15 01:52 ` Jerry Sievers <gsievers19@comcast.net>
2018-09-15 02:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-09-15 02:29 ` Jerry Sievers <gsievers19@comcast.net>
2018-09-15 21:33 ` Martín Fernández <fmartin91@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox