When the agent loses its session, it is supposed to stop interaction with the dispatcher and try to reestablish a session. This process has a backoff loop that handles this well. In the issue referenced below, when we have a failure to elect a leader, we see that an error to updating the task status doesn't cause the agent to fallback into the retry state, resulting in agent spamming log messages.
Please see moby/moby#26038 for further details.
To address this, we will have to poison the session when an invalid session is encountered.
cc @aaronlehmann @LK4D4