Driver health is published AFTER teardown, so GetHealth() can report Healthy with a disposed client #517
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in the MTConnect Task 9 code review (PR #506), deliberately not fixed there because MTConnect follows the existing fleet convention — fixing one driver alone would create inconsistency.
Symptom
GetHealth()can report Healthy while the driver's client is already disposed.Cause
ShutdownAsyncand theInitializeAsyncfailure path bothawait TeardownCoreAsync()— disposing the client and clearing state — before callingWriteHealth(...). AGetHealth()landing in that window observes the stale, pre-teardown health value.This is a fleet-wide ordering pattern, not an MTConnect regression:
ModbusDriver.cs:247-249has the identical teardown-then-write sequence.Suggested fix
A fleet-wide pass: write a transitional /
Degradedhealth value before disposing, so the race window leans conservative rather than optimistic. Audit every driver for the same ordering while doing it.