Re: Vacuum not cleaning up rows. - Mailing list pgsql-admin

From Tom Lane
Subject Re: Vacuum not cleaning up rows.
Date
Msg-id 31037.1560988222@sss.pgh.pa.us
Whole thread Raw
In response to Vacuum not cleaning up rows.  ("S. Bob" <sbob@quadratum-braccas.com>)
Responses Re: Vacuum not cleaning up rows.
List pgsql-admin
"S. Bob" <sbob@quadratum-braccas.com> writes:
> we have a table that consistently has 2x the number of dead rows than 
> live rows.
> I've done some digging and it looks like somehow the application is 
> holding shared locks that force vacuum to not cleanup rows.

This is not a locking issue; if it were, vacuum would be unable to
scan the table at all.

What it is is a snapshot issue: that is, some transaction has a snapshot
that's old enough to allow it to see those dead rows if it were to look.
So vacuum can't remove the rows for fear of causing transactional
consistency failures.

What you want to do is look into pg_stat_activity for transactions with
very old start times, and then cancel them or otherwise force them to
terminate.  Also, if there are no obvious candidates there, you might
be having a problem with prepared transactions --- look into
pg_prepared_xacts to see if there are any old ones of those.

            regards, tom lane



pgsql-admin by date:

Previous
From: "S. Bob"
Date:
Subject: Vacuum not cleaning up rows.
Next
From: Rui DeSousa
Date:
Subject: Re: zero data loss recovery is possbile with pgbackrest tool?