Closed seankearon closed 4 years ago
It definitely sounds like that would be an improvement!
Great! I'll send over a PR tomorrow 😸
(⌐■_■) 👍
It turns out that, as this was such a great idea, you're done it already! 😊
The problem was with us. The account we run Rebus under doesn't have create table rights. So, we are creating the tables separately using SQL and we managed to forget to create that index. Mea culpa!
Wow, that's good news!! 😁
TL; DR: our DBAs added the index below to fix a performance issue on our servers. Is this something worth adding to the Rebus.SqlServer?
The Longer Version
We're starting to use Rebus against some SQL databases in our data centers to run some fairly simple sagas. We started to notice deadlock issues, which I investigated.
The deadlocks were happening during deletion attempts on rows in the
SagaIndexes
table. Our DBAs helped and suggested we add an index against theid
field of the 'SagaIndexes' table. Their feedback was:This makes sense, but the strange thing was that I could not reproduce the deadlocks on other databases. I tried the local SQL instance on my development laptop and very small SQL Azure instance (General Purpose: Serverless, Gen5, 1 vCore) that costs less than a pint of been in London to run for a month.
The small console apps I used to test the databases is here. We loaded the system with 50 messages first, then started the bus to process the messages. This quickly gave us deadlock errors on our servers.
When the index was added, these deadlocks went away and throughput of messages on the test bus went from 1 message every 3 seconds to 2 messages per second.