Working around MySQL error “Deadlock found when trying to get lock; try restarting transaction”

If you are using InnoDB or any row-level transactional RDBMS, then it is possible that any write transaction can cause a deadlock, even in perfectly normal situations. Larger tables, larger writes, and long transaction blocks will often increase the likelihood of deadlocks occurring. In your situation, it’s probably a combination of these. The only way … Read more

What does “lock | communication buffer resources” mean?

I would interpret the message as a deadlock on some combination of Lock resources or Communication Buffer resources. “Lock resources” are ordinary object locks, and “Communication Buffer resources” are exchangeEvents used for combining results of parallel queries. These are described further in https://blogs.msdn.microsoft.com/bartd/2008/09/24/todays-annoyingly-unwieldy-term-intra-query-parallel-thread-deadlocks/ where the relevant paragraph is: An “exchangeEvent” resource indicates the presence of … Read more

Implementing retry logic for deadlock exceptions

How about something like this: public T DeadlockRetryHelper<T>(Func<T> repositoryMethod, int maxRetries) { int retryCount = 0; while (retryCount < maxRetries) { try { return repositoryMethod(); } catch (SqlException e) // This example is for SQL Server, change the exception type/logic if you’re using another DBMS { if (e.Number == 1205) // SQL Server error code … Read more

What is the difference between “wait-die” and “wound-wait” deadlock prevention algorithms?

Wait-Die scheme It is a non-preemptive technique for deadlock prevention. When transaction Tn requests a data item currently held by Tk, Tn is allowed to wait only if it has a timestamp smaller than that of Tk (That is Tn is older than Tk), otherwise Tn is killed (“die”). In this scheme, if a transaction … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)