skupperproject / skupper-router

An application-layer router for Skupper networks
https://skupper.io
Apache License 2.0
14 stars 17 forks source link

Q2 unblock hander callback race #1144

Open kgiusti opened 1 year ago

kgiusti commented 1 year ago

There is a race in the way Q2 signals that the ingress connection has been unblocked. It is possible that the unblock handler callback runs simultaneously with the deletion of the ingress connection that is being unblocked. This can lead to a crash.

Issue #1134 is an example of this race. Since the TCP adaptor has its own ingress flow control window the fix for #1134 is to simply not use Q2 for TCP. However all the other protocols - including AMQP - are susceptible to this race.

kgiusti commented 1 year ago

Potential solution: the ingress connection should de-register its Q2 unblock handler prior to the connection being closed. This should happen when the message is marked "receive complete" for example since Q2 will no longer apply at that point.

The de-registering of the handler must be synchronized with the callback of that handler in a way to ensure the callback can never occur after the handler is de-registered.