excellarateinc / voyage-api-dotnet

Enterprise grade C# .NET Web Services API implementing industry standard best practices
Apache License 2.0
16 stars 14 forks source link

Activity Audit Middleware deadlocks #164

Closed raymer closed 6 years ago

raymer commented 6 years ago

From Jason Kissinger: "FYI -- we had to disable the ActivityAuditMiddleware for the client because we were getting intermittent deadlocks trying to add audit records which resulted in 500 on those requests."

Look into ways to resolve deadlocks.

aeslinger0 commented 6 years ago

@raymer I suspect it's the SELECT that happens to get the primary key after the entity is inserted. This step isn't needed since we don't do anything with the key anyway. We could write a stored procedure to insert the record instead to avoid the select. I don't see any stored procedures in the app currently. Any concerns with this approach?

raymer commented 6 years ago

@aeslinger0 I actually wasn't able to reproduce this. I even installed a load tool to hit the API with tons of simultaneous requests with no luck. Not sure if we should refactor that if we can't reproduce it. Otherwise we don't know if it fixed it or not. Thoughts?

aeslinger0 commented 6 years ago

@raymer We may never know if we fixed it or not, being that it's intermittent, but we might get lucky. We can reduce the variables at play by bypassing Entity Framework and avoiding the SELECT's altogether. The worst that could happen is that people would still get deadlocks, but they're already getting them today.

raymer commented 6 years ago

@aeslinger0 sure sounds good.