NServiceBus/NServiceBus — pull request #245 by tmyklebust (2012-03-23 23:36:26+00:00)
Title: Timeout handling issues

I've been looking deeply into the timeout logic after we experienced some strange behavior.

The first issue was related to timeouts that expired before they were added. There is a timing issue causing some timeouts not to be deleted from the persistence store (raven) after they are fired. The result is that they are fired once more when the endpoint is restarted (since the timeouts are loaded from the store again). This is most likely related to stale indexes in raven.

There is also another issue: The current implementation does not properly support more than one timeout for each saga, but it does not fail when registering a second timeout. Actually the in-memory timeout manager does support it partially and will be able to handle multiple timeouts if there is no restart, but then every time a timeout expires, the persistence store will delete all timeouts for the saga, since IPersistTimeouts only implements a Remove(Guid sagaId).

I'm not sure if these bugs can be fixed without a breaking change, so I have changed the implementation to handle these things as I think they should be.