Add last commit LSN to pg_last_committed_xact()

Поиск
Список
Период
Сортировка
От James Coleman
Тема Add last commit LSN to pg_last_committed_xact()
Дата
Msg-id CAAaqYe9QBiAu+j8rBun_JKBRe-3HeKLUhfVVsYfsxQG0VqLXsA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Add last commit LSN to pg_last_committed_xact()  (Robert Haas <robertmhaas@gmail.com>)
Re: Add last commit LSN to pg_last_committed_xact()  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
I'd recently been thinking about monitoring how many bytes behind a
logical slot was and realized that's not really possible to compute
currently. That's easy enough with a physical slot because we can get
the current WAL LSN easily enough and the slot exposes the current LSN
positions of the slot. However for logical slots that naive
computation isn't quite right. The logical slot can't flush past the
last commit, so even if there's 100s of megabytes of unflushed WAL on
the slot there may be zero lag (in terms of what's possible to
process).

I've attached a simple patch (sans tests and documentation) to get
feedback early. After poking around this afternoon it seemed to me
that the simplest approach was to hook into the commit timestamps
infrastructure and store the commit's XLogRecPtr in the cache of the
most recent value (but of course don't write it out to disk). That the
downside of making this feature dependent on "track_commit_timestamps
= on", but that seems reasonable:

1. Getting the xid of the last commit is similarly dependent on commit
timestamps infrastructure.
2. It's a simple place to hook into and avoids new shared data and locking.

Thoughts?

Thanks,
James Coleman

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: Why is src/test/modules/committs/t/002_standby.pl flaky?
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Why is src/test/modules/committs/t/002_standby.pl flaky?