Skip to Content Skip to content

1C / BAS / Practice

“Lock conflict during transaction”: what the error means and what to do about it

Locks are not a bug — excessive locks are

The message “Lock request time out period exceeded. HRESULT=80040E31, SQLSTATE=HYT00” means that one user’s transaction waited too long for data held by another transaction, and the DBMS gave up.

A lock is not an error

A lock is information that a resource has been taken by a particular user. It is a necessary way of sharing resources in a multi-user system: without it, two people could spend the same stock balance. The problem is excessive locks — when a transaction holds more data, or holds it longer, than it needs.

Where excessive locks come from

  • A query without a suitable index reads — and locks — far more rows than it needs.
  • Lock escalation: the DBMS replaces thousands of row locks with a lock on the whole table.
  • Long transactions: heavy calculations or user dialogs inside posting.
  • Automatic lock mode instead of managed locks in the configuration.

Timeout or deadlock: two different problems

A timeout means that someone waited in a queue for too long: the transaction ahead of them simply did not finish in time. A deadlock is different: two transactions each hold what the other needs, and neither can continue, so the DBMS picks a victim and rolls it back. Timeouts are usually cured by speeding up the transaction that holds the data; deadlocks by making all transactions take resources in the same order.

In practice, both often appear together during month-end closing or mass posting, when many users work with the same registers at once. Rescheduling heavy routine operations to the night helps for a while, but it hides the cause instead of removing it.

What to do

First, find out exactly who locks whom and on which data. For this, set up the BAS technology log to record locks and timeouts, and a SQL Server trace for long queries. Without these logs, any “fix” is guesswork.

Then remove the causes: add the missing indexes, rewrite heavy queries, shorten transactions and switch problem areas to managed locks. And make sure the next release does not bring the problem back — that is what regular performance support is for.