'pessimistic_locking': Select a Database Row Locking (Optimistic / Pessimistic)

Row Locking Overview

Choosing Between Optimistic and Pessimistic Row Locking

Enabling Pessimistic Locking

Row Locking Overview

There are two models for locking data in a database:

Note: By default, Lycia LowCode processes database row updates using Optimistic row locking. Set pessimistic_locking to 1 to select Pessimistic locking.

Choosing Between Optimistic and Pessimistic Row Locking

In most scenarios, Optimistic row locking is more efficient and offers higher performance.

Pessimistic row locking is useful if there are a lot of updates and relatively high chances of users trying to update data at the same time. Please keep in mind that the resource is locked from the time it is first accessed in a transaction until the transaction is finished, making it inaccessible to other transactions during that time. Therefore, if one program user attempts to make changes to the row that is being edited by another user, it will be impossible for the first user to add their changes to the database until the second user finishes working with that row’s data.

 

Return to top

Enabling Pessimistic Locking

Note: Before proceeding, get acquainted with the Settings Levels section of LyciaLowCode Settings page (the concept of scopes is essential for configuring multiple interactions and the multitable support).

The definitions like LET <setting_variable>.<setting_name> = <value> refer to the InteractForm_Settings level, while LET <setting_variable>.views["<db_table_name>"].<setting_name> = <value> refers to the View level.

This setting can be defined for:

InteractForm_Settings level: Yes

View level: Yes

Setting format:

<InteractForm_Settings>.pessimistic_locking INT

<InteractForm_Settings> here is the name for the settings variable you assign.

Example:

LET rec_settings.pessimistic_locking = 1 #Pessimistic locking enabled

Note: Alternatively, you can specify this setting in JSON array in .fm2 form file by the following example: Defining Settings in .fm2 Form File.

 

Return to top

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.