Mithilbatra opened a new pull request, #13363:
URL: https://github.com/apache/seatunnel/pull/13363

   ### Purpose of this pull request
   
   Fixes #13347.
   
   `DefaultSlotService` used an `initStatus` flag to decide whether `reset()` 
may reinitialize the slot service, but `requestSlot()` set it to `false` on 
every call. So any worker that had ever served a slot would, on the next 
`ResetResourceOperation`, rebuild `assignedSlots`, `unassignedSlots`, 
`contexts` and `slotServiceSequence`, even while its tasks were still running. 
That breaks `getSlotContext()` for those tasks, invalidates persisted 
`SlotProfile`s, and lets the same fixed slot be handed out twice.
   
   This PR:
   
   - removes the `initStatus` flag, so "initialized" and "safe to reset" are no 
longer conflated;
   - makes `reset()` `synchronized` and a no-op (with a warning) while the 
worker still has assigned slots or live slot contexts, and reinitializes only 
when it is empty.
   
   The graceful path from the issue (stop the owning task groups first, then 
rebuild) is left for a follow-up to keep this change small.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. A worker that still has assigned slots or live slot contexts now keeps 
its slot state when it receives `ResetResourceOperation`, and logs a warning 
instead of clearing it.
   
   ### How was this patch tested?
   
   Added `FixSlotResourceTest#testResetKeepsLiveSlotAssignment`. It assigns a 
fixed slot, calls `reset()`, and asserts that the assigned slot, its sequence, 
the unassigned slot count and the slot context are preserved. The test fails 
without this change.
   
   Ran locally (JDK 17): `FixSlotResourceTest`, `ResourceManagerTest`, 
`WorkerTagTest`, `JobMasterMasterFailoverResourceTest`, with 27 tests in total, 
all passing. `spotless:check` is clean.
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   * [ ] If you are contributing the connector code, please check that the 
following files are updated:
     1. Update 
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
 and add new connector information in it
     2. Update the pom file of 
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in 
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in 
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector 
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   


-- 
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]

Reply via email to