NServiceBus.SqlServer icon indicating copy to clipboard operation
NServiceBus.SqlServer copied to clipboard

Fix bug in BackOffStrategy that can lead to infinite wait time

Open PhilAch opened this issue 1 year ago • 2 comments

I stumbled upon a strange behavior regarding NSB and delayed messaged on SQL transport. Sometimes delayed messages would not be processed anymore, without any exception or anything being logged. They just stay in the .Delayed table and are not moved to their target table anymore. If they are moved there manually, the messages are processed normally.

In the logs I found occurrences of the following error: "The value needs to be either -1 (signifying an infinite timeout), 0 or a positive integer." in BackOffStrategy.WaitForNextExecution. This shows, that sometimes negative values can be calculated. And in case of a -1, it would lead to an infinite wait time, which could explain my noticed behavior.

Unfortunately I was not able to write a stable test to reproduce this behavior.

PhilAch avatar Jul 09 '24 10:07 PhilAch

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 09 '24 10:07 CLAassistant

@PhilAch thank you for your contribution. We will look into the changes and get back to you with more information.

tmasternak avatar Jul 09 '24 12:07 tmasternak

Hi @PhilAch, we took the liberty of tweaking your PR a bit i.e. adding a deterministic test, and fixing a bunch of other problems we discovered along the way.

tmasternak avatar Jul 18 '24 20:07 tmasternak

Hi @PhilAch, we took the liberty of tweaking your PR a bit i.e. adding a deterministic test, and fixing a bunch of other problems we discovered along the way.

Hi @tmasternak, glad to see. I thought about TimeProvider, but didn't dare to change it. Anyway, happy to see it and looking forward to it being released.

PhilAch avatar Jul 19 '24 20:07 PhilAch

Hi @PhilAch, I've just realized that we are not able to run CI for externally opened PRs. As a result, I've opened https://github.com/Particular/NServiceBus.SqlServer/pull/1392 and moved all the relevant data there.

tmasternak avatar Jul 22 '24 20:07 tmasternak