Pluggable Discovery entry to START_SYNC state may miss hardware changes #1654
Labels
conclusion: declined
Will not be worked on
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
Having recently implemented Pluggable Discovery, how to properly begin START_SYNC mode was one of the places I applied some intuition and guesswork. But I'm a little worried it still may not be fully correct, and may not be possible with the current Pluggable Discovery specification.
The main question in my mind is regarding a possible (though unlikely) race between the protocol commands and hardware changes. Following the Pluggable Discovery spec, a client like arduino-cli would need to use the LIST command first to learn of all the currently connected devices. Then it would issue STOP to return to the idle state, and then START_SYNC to begin tracking changes. But what happens if hardware changes after the last LIST command, but before START_SYNC begins?
As a proactive and perhaps paranoid (maybe I worry about this stuff too much) measure, Teensy's implementation of START_SYNC transmits a set of eventType add messages for all currently known devices when entering START_SYNC mode. I believe elsewhere the spec says redundant "add" events are allowed and are to be interpreted as updating existing info. But maybe even this is not good enough? What happens if hardware is removed during that time between the last LIST and entering START_SYNC mode? Would arduino-cli forever believe that hardware is still present, because it was connected at the time of the last LIST, and a "remove" eventType message is never transmitted because it's already gone by the time START_SYNC is supposed to transmit real-time changes.
Maybe we should rethink the "start_sync" eventType message? Currently it just replies with OK. Perhaps it should reply with a list of all currently connected devices, similar to the LIST response? If so, the Pluggle Discovery spec should require that the transition from the list conveyed in the "start_sync" eventType message to be real-time reporting of changes be atomic with respect to hardware changes.
The text was updated successfully, but these errors were encountered: