pg_gather icon indicating copy to clipboard operation
pg_gather copied to clipboard

New feature: prepared_xacts

Open ylacancellera opened this issue 11 months ago • 4 comments

Having xmin age from prepared_xacts could help I'm thinking of

select *, (now()-prepared)::INTERVAL as duration, age(transaction) as trx_age from pg_prepared_xacts order by age(transaction) desc;

ylacancellera avatar Mar 28 '24 15:03 ylacancellera

Thank you, @ylacancellera, for this feedback. This is something I also thought about previously. Unfortunately, I didn't see many cases of people using Prepared transactions / Distributed transactions / Two-phase commit in actual use cases. Is it for something like Citus? Please share your thoughts. I would appreciate your thoughts and feedback.

jobinau avatar Mar 29 '24 09:03 jobinau

This is just because it's one of the potential reason that could explain a wraparound/vacuum issue: it can hoard row versions So having xmin associated to prepared txs can give a more complete overview when dealing with vacuum issues

I agree, i did not see many cases either, but having an abandoned prepared tx could be useful in the rare cases it happens, it's too easy to miss

ylacancellera avatar Mar 29 '24 10:03 ylacancellera

aah, that is an interesting requirement. that makes sense. Basically, we need to rule out the possibility of some distributed transactions holding any xmin reference. Right ? If yes, we need not list all prepared transactions, instead, report if there is one, in the "Findings" section.

jobinau avatar Mar 30 '24 09:03 jobinau

Actually yes, having the oldest xmin age and when it was prepared in findings seems more than enough

ylacancellera avatar Mar 30 '24 10:03 ylacancellera