Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-02 Thread Tom Lane
Andres Freund writes: > On 2020-04-01 19:57:32 -0400, Tom Lane wrote: >> Agreed, but just knowing what the oldest xmin is doesn't help you >> find *where* it is. Maybe what we need is a view showing all of >> these potential sources of an old xmin. > +1. This would be extermely useful. It's a v

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-02 Thread Andres Freund
Hi, On 2020-04-01 19:57:32 -0400, Tom Lane wrote: > Alvaro Herrera writes: > > On 2020-Apr-01, Tom Lane wrote: > >> The fact that I had to use max(age(...)) in that sample query > >> hints at one reason: it's really hard to do arithmetic correctly > >> on raw XIDs. Dealing with wraparound is a p

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-02 Thread James Coleman
On Thu, Apr 2, 2020 at 12:13 AM Craig Ringer wrote: > > > > > On Thu, 2 Apr 2020 at 07:57, Tom Lane wrote: >> >> Alvaro Herrera writes: >> > On 2020-Apr-01, Tom Lane wrote: >> >> The fact that I had to use max(age(...)) in that sample query >> >> hints at one reason: it's really hard to do arith

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread Craig Ringer
On Thu, 2 Apr 2020 at 07:57, Tom Lane wrote: > Alvaro Herrera writes: > > On 2020-Apr-01, Tom Lane wrote: > >> The fact that I had to use max(age(...)) in that sample query > >> hints at one reason: it's really hard to do arithmetic correctly > >> on raw XIDs. Dealing with wraparound is a probl

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread Tom Lane
Alvaro Herrera writes: > On 2020-Apr-01, Tom Lane wrote: >> The fact that I had to use max(age(...)) in that sample query >> hints at one reason: it's really hard to do arithmetic correctly >> on raw XIDs. Dealing with wraparound is a problem, and knowing >> what's past or future is even harder.

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread James Coleman
On Wed, Apr 1, 2020 at 5:58 PM Alvaro Herrera wrote: > > On 2020-Apr-01, Tom Lane wrote: > > > James Coleman writes: > > > To my knowledge the current oldest xmin (GetOldestXmin() if I'm not > > > mistaken) isn't exposed directly in any view or function by Postgres. > > > > You could do something

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread Alvaro Herrera
On 2020-Apr-01, Tom Lane wrote: > James Coleman writes: > > To my knowledge the current oldest xmin (GetOldestXmin() if I'm not > > mistaken) isn't exposed directly in any view or function by Postgres. > > You could do something like > > select max(age(backend_xmin)) from pg_stat_activity; > >

Re: Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread Tom Lane
James Coleman writes: > To my knowledge the current oldest xmin (GetOldestXmin() if I'm not > mistaken) isn't exposed directly in any view or function by Postgres. You could do something like select max(age(backend_xmin)) from pg_stat_activity; though I'm not sure whether that accounts for abso

Proposal: Expose oldest xmin as SQL function for monitoring

2020-04-01 Thread James Coleman
Currently there's no good way that I'm aware of for monitoring software to check what the xmin horizon is being blocked at. You can check pg_stat_replication and pg_replication_slots and txid_snapshot_xmin(txid_current_snapshot()) and so on, but that list can grow, and it means monitoring setups ne