Jackie-Jiang opened a new pull request, #19590:
URL: https://github.com/apache/pinot/pull/19590

   ## Summary
   
   `DefaultClusterConfigChangeHandler` dispatches Helix cluster config 
callbacks to `PinotClusterConfigChangeListener`s. `process()` was 
`synchronized`, but `registerClusterConfigChangeListener()` was not: it added 
the listener to the list and then called `onChange` with a snapshot of 
`_properties` read without the lock. Once the handler is attached to Helix, 
that leaves a race for any listener registered afterwards:
   1. Registration adds the listener and reads snapshot `A`.
   2. A Helix callback runs `process(B)`; the listener is already in the list, 
so it is applied `B`.
   3. Registration resumes and applies snapshot `A`, overwriting `B`. The 
listener keeps the stale value until that key changes again.
   
   The window is a few milliseconds at startup and needs a cluster config 
change to land in it, so it is unlikely in practice, but the fix is one 
keyword: every method on the handler is now `synchronized` on the instance, so 
a registration that arrives during a change waits and then receives the 
snapshot that change produced.
   
   With a single lock in place, the class no longer needs the pieces that 
compensated for its absence, so they are removed: the `volatile` on the config 
map (the getter is serialized too), the `CopyOnWriteArrayList` (the only 
mutation path is the serialized registration), the `ImmutableSet` copy of the 
changed keys (`getChangedProperties` already returns a fresh set or a key-set 
view of an immutable map), the private `process()` indirection and the 
constructor. `Map.copyOf` stays: the Helix `ZNRecord` map is mutable, and the 
snapshot is handed to every listener and to `getClusterConfigs()` callers. The 
`CALLBACK START` / `DONE` log lines are replaced by one line listing the 
changed keys.
   
   No API change: the `PinotClusterConfigProvider` contract, the no-arg 
constructor and the Helix callback signature are unchanged.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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