Skip to content

Fix resgroup: pgstat_report_resgroup, is_session_in_group, duplicate totalExecuted#1707

Open
lss602726449 wants to merge 3 commits intoapache:cbdb-postgres-mergefrom
lss602726449:fix_orca_perminfo
Open

Fix resgroup: pgstat_report_resgroup, is_session_in_group, duplicate totalExecuted#1707
lss602726449 wants to merge 3 commits intoapache:cbdb-postgres-mergefrom
lss602726449:fix_orca_perminfo

Conversation

@lss602726449
Copy link
Copy Markdown
Contributor

Summary

  • Restore pgstat_report_resgroup() calls that were commented out during PG16 merge (MERGE16_FIXME), so pg_stat_activity correctly shows rsgid/rsgname
  • Add pgstat_report_resgroup() in check_and_unassign_from_resgroup() to restore st_rsgid after Assign-to-Bypass transition, fixing rsgname='unknown' in pg_stat_activity
  • Fix is_session_in_group() plpython function: PG16 removed con{session_id} from process titles, breaking ps | grep. Replaced with gp_stat_activity JOIN gp_segment_configuration
  • Remove duplicate totalExecuted++ in check_and_unassign_from_resgroup() that caused double-counting when a query transitions from Assign to Bypass state

Test plan

  • Run resgroup_move_query isolation2 test — verify rsgname shows correctly instead of unknown
  • Run resgroup_bypass isolation2 test — verify num_executed delta is 1 (not 2)
  • Run resgroup_auxiliary_tools_v2 isolation2 test — verify is_session_in_group function creates without error
  • Run resgroup_syntax isolation2 test — verify is_session_in_group returns correct results

liushengsong 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.
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.

1 participant