azure-webjobs-sdk
azure-webjobs-sdk copied to clipboard
SingletonListener releases lease before stopping the inner listener
The SingletonListener implementation of IListener
may lead an uneducated observer to believe the inner listener is only executed as a singleton, i.e. is running only as long as the lock lease is being held.
- First the lock lease is acquired, see the source.
- Then the inner listener is started, see the source.
However, when during the shutdown, the order remains the same, leaving a bit of inner listener run after the lock is no longer leased.
- First release lock lease, see the source
- Then the inner listener is stopped, see the source.
Expected behavior
I'd expect the SingletonListener
first stop the inner listener and only after that release the lock.
Actual behavior
The inner listener may run after the lock has been release and another singleton listener instance acquired the lock and started its own inner listener. As far as I can tell, it's always been like this, both v2 and v3.
Is that on purpose? I managed to deal with it in my own code, but I must say I find the behaviour quite surprising.
Tagging @fabiocav for triage.
Appears to have been fixed in https://github.com/Azure/azure-webjobs-sdk/pull/2898, so it was not in fact intentional!