ybapat opened a new pull request, #57566:
URL: https://github.com/apache/spark/pull/57566

   ### What changes were proposed in this pull request?
   
   `ResourceProfile.nextProfileId` was initialized to `new AtomicInteger(0)`, 
so the first call to `getNextProfileId()` returned `0` — which is identical to 
`DEFAULT_RESOURCE_PROFILE_ID`. Any custom `ResourceProfile` created before the 
default profile was initialized would receive ID `0`, colliding with the 
default profile.
   
   This PR fixes the counter to start at `1`, so ID `0` remains exclusively 
reserved for the default profile.
   
   Changes:
   - Start `nextProfileId` at `1` instead of `0` in `ResourceProfile` companion 
object.
   - Add `resetNextProfileIdForTesting()` (`private[spark]`) to enable test 
isolation without exposing the reset in production code paths.
   - Add `afterEach` reset call in `ResourceProfileSuite` to prevent 
test-order-dependent failures.
   - Add a regression test that creates a custom profile before the default and 
asserts no ID collision.
   
   ### Why are the changes needed?
   
   Without this fix, `new ResourceProfileBuilder().build()` called before 
`ResourceProfile.getOrCreateDefaultProfile()` produces a profile with `id == 0 
== DEFAULT_RESOURCE_PROFILE_ID`, which can lead to incorrect resource 
allocation or scheduling decisions.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The fix only affects internal ID assignment. The default profile always 
receives ID `0` and custom profiles now always start at ID `1`.
   
   ### How was this patch tested?
   
   - Existing `ResourceProfileSuite` passes.
   - New test `"custom ResourceProfile id must not collide with 
DEFAULT_RESOURCE_PROFILE_ID"` covers the regression case.
   
   Closes #57498
   
   Co-Authored-By: Claude Sonnet 4.6 <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to