Fix resgroup: pgstat_report_resgroup, is_session_in_group, duplicate totalExecuted#1707
Open
lss602726449 wants to merge 3 commits intoapache:cbdb-postgres-mergefrom
Open
Fix resgroup: pgstat_report_resgroup, is_session_in_group, duplicate totalExecuted#1707lss602726449 wants to merge 3 commits intoapache:cbdb-postgres-mergefrom
lss602726449 wants to merge 3 commits intoapache:cbdb-postgres-mergefrom
Conversation
added 3 commits
April 29, 2026 17:29
…, fix duplicate totalExecuted
Three issues fixed:
1. pgstat_report_resgroup was commented out during PG16 merge (MERGE16_FIXME).
Restore all call sites so pg_stat_activity correctly shows rsgid/rsgname.
2. In check_and_unassign_from_resgroup, the Assign-to-Bypass transition calls
UnassignResGroup which clears st_rsgid, but pgstat_report_resgroup was not
called afterward to restore it. This caused pg_stat_activity to show
rsgname='unknown' for queries that switch from normal assign to bypass mode.
3. is_session_in_group plpython function used `ps -ef | grep con{session_id}`
to find process PIDs, but PG16 removed con{session_id} from process titles.
Empty grep result meant empty set, and empty.issubset(any) = True, so the
function always returned true. Fixed to use gp_stat_activity JOIN
gp_segment_configuration instead.
4. Remove duplicate totalExecuted++ in check_and_unassign_from_resgroup that
caused double-counting when a query transitions from Assign to Bypass state.
…segments The try/except fallback logic in FullRecovery.run() was commented out during the PG16 merge. This caused pg_basebackup to fail when recovering new segments (e.g. during gpexpand) that don't yet have the internal_wal_replication_slot. Restore the fallback to retry with create_slot=True when the slot doesn't exist.
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.
Summary
pgstat_report_resgroup()calls that were commented out during PG16 merge (MERGE16_FIXME), sopg_stat_activitycorrectly showsrsgid/rsgnamepgstat_report_resgroup()incheck_and_unassign_from_resgroup()to restorest_rsgidafter Assign-to-Bypass transition, fixingrsgname='unknown'inpg_stat_activityis_session_in_group()plpython function: PG16 removedcon{session_id}from process titles, breakingps | grep. Replaced withgp_stat_activity JOIN gp_segment_configurationtotalExecuted++incheck_and_unassign_from_resgroup()that caused double-counting when a query transitions from Assign to Bypass stateTest plan
resgroup_move_queryisolation2 test — verifyrsgnameshows correctly instead ofunknownresgroup_bypassisolation2 test — verifynum_executeddelta is 1 (not 2)resgroup_auxiliary_tools_v2isolation2 test — verifyis_session_in_groupfunction creates without errorresgroup_syntaxisolation2 test — verifyis_session_in_groupreturns correct results