The transaction lock management mechanism enables you to lock changes to data using the 1C:Enterprise platform, rather than relying on the database management system. This approach implements locks based on business area concepts rather than underlying DBMS data structures. As a result, locks are more precise, and user concurrency is improved.

1C:Enterprise configurations support three transaction lock management modes:

  • Automatic
  • Managed (default for new configurations)
  • Combined Automatic and Managed

In automatic mode, transaction isolation levels (Repeatable Read, Serializable) are enforced by the DBMS. These isolation levels ensure consistent and reliable data reads, so developers do not need to manage locks manually.

Managed mode lets you increase concurrency for users in a client-server environment by using a lower isolation level (Read Committed). When saving data in a transaction, objects in the 1C:Enterprise language automatically lock the necessary data. Developers must take responsibility for locking when business logic requires consistent reads and integrity within a transaction.

Combined mode allows selective use of managed locking for certain configuration objects. This mode is useful for optimizing concurrency for high-usage objects (such as specific documents) or gradually switching large configurations to managed lock control.

A comparative summary of automatic and managed lock modes is shown below:

Lock Mode in Transaction

DBMS

File Database

MS SQL Server

PostgreSQL

Automatic

Type of Lock

Table

Record

Table

Transaction Isolation Level

Serializable

Repeatable Read or Serializable

Read Committed

Managed

Type of Lock

Table

Record

Record

Transaction Isolation Level

Serializable

Read Committed

Read Committed

Transaction lock management is most frequently required during document posting, when you need to read data and then write updates to the same database tables (for example, when performing inventory checks during posting).

For this purpose, record sets of accumulation and accounting registers have a LockForUpdate property.

If you need to check balances and then record movements in the same register, set this property for the register’s record set in the Movements property.

If Mode = DocumentPostingMode.RealTime Then RegisterRecords.Inventory.LockForUpdate = True; EndIf;

This property works as if the developer manually coded the necessary managed lock in 1C:Enterprise. The platform automatically applies the managed lock when saving the record set. As a result, other managed transactions that request similar locks cannot read the register until the current transaction completes.

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.