Skip to content

fix(roles): ensure distinct user roles in aggregate queries - #11686

Open
MatheuslFavaretto wants to merge 4 commits into
cloudnative-pg:mainfrom
MatheuslFavaretto:dev/11624
Open

MatheuslFavaretto wants to merge 4 commits into
cloudnative-pg:mainfrom
MatheuslFavaretto:dev/11624

Conversation

@MatheuslFavaretto

Copy link
Copy Markdown

Fixes #11624

Problem

On PostgreSQL 16+, a role can be a member of the same group twice (two grantors). The operator reads this as {grp,grp}, while the spec has [grp]. They never match, so the role stays in pending-reconciliation forever, with no error.

Fix

Add DISTINCT to the two membership queries in roles/postgres.go.

Testing

On kind and EKS, PostgreSQL 18.6:

  • Before (1.30.1): role stuck in pending-reconciliation
  • After (this branch): role becomes reconciled
  • Adding and removing inRoles still works
  • go test passes

@MatheuslFavaretto
MatheuslFavaretto requested a review from a team as a code owner October 17, 2026 20:23
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Managed role stays pending-reconciliation when a membership has several grantor rows

2 participants