Add infrastructure to identify what holds back the xid horizon - #7
Open
shinyaaa wants to merge 2 commits into
Open
Add infrastructure to identify what holds back the xid horizon#7shinyaaa wants to merge 2 commits into
shinyaaa wants to merge 2 commits into
Conversation
Introduce GetXidHorizonBlocker() and GetXidHorizonBlockers() in procarray.c. Given an xid horizon, these search the proc array and the replication slots for what is preventing it from advancing: active transactions, idle-in-transaction sessions, prepared transactions, hot standby feedback (held either in a walsender's PGPROC or, when a physical slot is in use, in the slot itself), and logical replication slots. A blocker is described by the new XidHorizonBlocker struct, and the candidates are ranked by XidHorizonBlockerType so that the single highest-priority (root-cause) blocker can be reported. A companion GetPreparedTransactionGid() in twophase.c resolves the GID of a blocking prepared transaction. This is infrastructure with no in-tree caller yet. A following patch uses it to report the blocker in VACUUM's log output, and the same API can underpin a future SQL-callable view that lists every blocker. Author: Shinya Kato <shinya11.kato@gmail.com> Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Japin Li <japinli@hotmail.com> Discussion: https://postgr.es/m/CAOzEurSgy-gDtwFmEbj5+R9PL0_G3qYB6nnzJtNStyuf87VSVg@mail.gmail.com
When VACUUM encounters recently-dead tuples that cannot be removed, it is often unclear what is preventing the xid horizon from advancing. Using the infrastructure added in the previous patch, VACUUM (VERBOSE) and log_autovacuum output now report the highest-priority blocker that is holding back OldestXmin, with identifying details: the backend pid, the prepared transaction GID, the standby application_name, or the replication slot name. Because the horizon was computed earlier, the result is best-effort: the original blocker may have already committed by the time it is looked up, in which case a different blocker or none at all may be reported. Author: Shinya Kato <shinya11.kato@gmail.com> Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Sami Imseih <samimseih@gmail.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Japin Li <japinli@hotmail.com> Discussion: https://postgr.es/m/CAOzEurSgy-gDtwFmEbj5+R9PL0_G3qYB6nnzJtNStyuf87VSVg@mail.gmail.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce GetXidHorizonBlocker() and GetXidHorizonBlockers() in
procarray.c. Given an xid horizon, these search the proc array and the
replication slots for what is preventing it from advancing: active
transactions, idle-in-transaction sessions, prepared transactions, hot
standby feedback (held either in a walsender's PGPROC or, when a physical
slot is in use, in the slot itself), and logical replication slots.
A blocker is described by the new XidHorizonBlocker struct, and the
candidates are ranked by XidHorizonBlockerType so that the single
highest-priority (root-cause) blocker can be reported. A companion
GetPreparedTransactionGid() in twophase.c resolves the GID of a blocking
prepared transaction.
This is infrastructure with no in-tree caller yet. A following patch
uses it to report the blocker in VACUUM's log output, and the same API
can underpin a future SQL-callable view that lists every blocker.
Author: Shinya Kato shinya11.kato@gmail.com
Reviewed-by: wenhui qiu qiuwenhuifx@gmail.com
Reviewed-by: Fujii Masao masao.fujii@gmail.com
Reviewed-by: Sami Imseih samimseih@gmail.com
Reviewed-by: Dilip Kumar dilipbalaut@gmail.com
Reviewed-by: Japin Li japinli@hotmail.com
Discussion: https://postgr.es/m/CAOzEurSgy-gDtwFmEbj5+R9PL0_G3qYB6nnzJtNStyuf87VSVg@mail.gmail.com