qiuyanjun888 commented on PR #18416:
URL: 
https://github.com/apache/dolphinscheduler/pull/18416#issuecomment-5126868990

   > Please make all state transitions atomic and use one synchronization 
strategy for every read/write. Connection callbacks should only run when their 
corresponding transition succeeds.
   
   Thanks for pointing this out. Fixed in commit `79cc4a0cde`.
   
   The server state now uses one synchronization strategy consistently:
   
   - `start()`, `getServerState()`, the `close()` state update, and all 
heartbeat state transitions synchronize on the same server instance.
   - Successful heartbeats use a guarded `SUSPENDED -> STARTED` transition.
   - Heartbeat exceptions use a guarded `STARTED -> SUSPENDED` transition.
   - Expired heartbeat records use a guarded `STARTED/SUSPENDED -> 
DISCONNECTED` transition.
   - Reconnect and disconnect callbacks run inside their corresponding 
synchronized transition, only after the expected source state is confirmed. If 
`close()` wins and sets `STOPPED`, later heartbeat results cannot overwrite it 
or emit reconnect/disconnect callbacks.
   
   I also added the two requested race regressions:
   
   - `close()` racing with a successful heartbeat while `SUSPENDED`.
   - `close()` racing with a heartbeat exception while `STARTED`.
   
   Both assert that `STOPPED` remains final and that no reconnect/disconnect 
callback fires after shutdown.
   
   Verification:
   
   `./mvnw clean -pl 
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc
 -am -DskipITs -Dtest=JdbcRegistryServerTest 
-Dsurefire.failIfNoSpecifiedTests=false test`
   
   Result: 7 tests, 0 failures, 0 errors; reactor build succeeded.


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