Skip to content

Gitlab Collector: Xid collector and test #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Sticksman
Copy link
Contributor

@Sticksman Sticksman commented Jun 28, 2023

Split from #819

Will need to merge collector_test with #841

Signed-off-by: Felix Yuan <[email protected]>
Signed-off-by: Felix Yuan <[email protected]>
Signed-off-by: Felix Yuan <[email protected]>
@Sticksman Sticksman force-pushed the cleanup/gitlab-exporter-xid branch from 53d8c6f to 4d68e2d Compare July 10, 2023 17:42
@danzika
Copy link

danzika commented Jul 30, 2025

Hello @Sticksman, thanks for this PR, it addresses exactly what I was looking for. May I just kindly suggest the SQL enhancement so that it provides somewhat more thorough insight?

SELECT v.current_xid, v.committed_max_age, (2147483647 - v.committed_max_age) % (2^52)::bigint AS committed_xids_until_wraparound, CASE WHEN pg_is_in_recovery() THEN NULL::bigint ELSE txid_snapshot_xmin(txid_current_snapshot()) % (2^52)::bigint END AS uncommitted_max_age, CASE WHEN pg_is_in_recovery() THEN NULL::bigint ELSE (2147483647 - (txid_current() - txid_snapshot_xmin(txid_current_snapshot()))) END uncommitted_xids_until_wraparound FROM ( SELECT CASE WHEN pg_is_in_recovery() THEN NULL::bigint ELSE txid_current() % (2^52)::bigint END AS current_xid, --current xid CASE WHEN pg_is_in_recovery() THEN NULL::bigint ELSE MAX(age(c.relfrozenxid))::bigint END as committed_max_age FROM pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid WHERE c.relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') ) v;

With these metrics, it would address both committed and uncommitted transactions and also provide "how far from wraparound" the DB is, directly usable by DBAs.
And extrapolating the current_xid trend, it could also help to estimate how much time there is till wraparound at "current" transaction rate.

Hope this helps, kind regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants