E
E
Evgeny Glebov2016-11-18 12:12:06
ORM
Evgeny Glebov, 2016-11-18 12:12:06

What is the best way to bypass blocking?

Hello.
I have client request handlers on the server. It goes something like this:

Запрос
{
  НачалоТранзакции (IsolationLevel=Snapshot)
  {
    try
    {
      repo.UserRepo.ChangeSomething(..);
      repo.ShipRepo.ChangeSomething(..);
      repo.BuildingRepo.ChangeSomething(..);
      ...

      SaveChanges(); 
      Commit();
    }
    catch
    {
      Rollback();
      !!! Если произошла взаимоблокировка в транзакции, то повторить транзакцию заново
    }
  }
}

As a result, if a deadlock occurs, then this transaction is rolled back and tries again.
While everything is working fine. Sometimes deadlocks happen. But the more requests from users, the more deadlocks (= brakes)
Are there any solutions? I studied different methods, but I do not know how to apply in my case.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2016-11-18
@GLeBaTi

* Make queues in the context of intersecting mutable data
or
* Make locks (SELECT WITH LOCK) on intersecting mutable resources
Also optimize operations - the faster they work, the less conflicts.
At high loads, you can try 2-phase commit, sharding, partitioning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question