Skip to content

Fix inverted cpuset assignment#1863

Open
nix-oss wants to merge 2 commits into
apache:mainfrom
nix-oss:fix-cpuset-order
Open

Fix inverted cpuset assignment#1863
nix-oss wants to merge 2 commits into
apache:mainfrom
nix-oss:fix-cpuset-order

Conversation

@nix-oss

@nix-oss nix-oss commented Jul 26, 2026

Copy link
Copy Markdown

Fixes #1862

What does this PR do?

Fix inverted cpuset assignment in getCpuSetByRole(). The function returned the wrong cpuset for coordinator and segment roles when the cpuset string contains a semicolon separator (e.g., "0-7;0-15"). This caused incorrect CPU affinity settings on clusters.

Additionally, this PR addresses the suggestion from the @my-ship-it to return a palloc'd copy instead of a pointer into the caller's string.

A unit test for getCpuSetByRole() is also added to guard against future regressions.

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Test Plan

  • Unit tests added/updated

Impact

Performance:
This fix ensures that CPU cores are assigned to the coordinator and segments exactly as configured by the administrator. It prevents unintended usage of cores that may be reserved for other critical system tasks.

User-facing changes:
Users can now successfully set cpuset strings with a semicolon separator (e.g., ALTER RESOURCE GROUP ... SET CPUSET '4-7;9-17') without receiving a "cpu cores unavailable" error.

Checklist

  • Followed contribution guide
  • Added/updated documentation
  • Reviewed code for security implications
  • This PR contains AI-assisted code generation

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @nix-oss welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!

Comment thread src/backend/commands/test/resgroupcmds_test.c
@nix-oss
nix-oss requested a review from tuhaihe July 26, 2026 13:45
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.

[Bug] Incorrect cpuset role assignment in getCpuSetByRole()

2 participants