# Locks

## Overview

Database locks are tools designed to stop multiple transactions from altering identical data simultaneously or to prevent a transaction from accessing data that is undergoing modification by another transaction.

### Acquire locks programmatically

You can acquire a lock programmatically by using Database Manager [acquireLock](/reference/servoycore/dev-api/database-manager.md#acquirelockfoundset-recordindex-lockname) method.

Example:

```javascript
databaseManager.acquireLock(foundset,1,'myLock')
```

### Release locks programmatically

You can release a lock programmatically by using Database Manager [releaseAllLocks](/reference/servoycore/dev-api/database-manager.md#releasealllockslockname) method.\
You can also release all locks by using Database Manager [releaseAllLocks](/reference/servoycore/dev-api/database-manager.md#releasealllocks) method.

Example:

```javascript
databaseManager.releaseAllLocks('myLock'); //release specific lock
databaseManager.releaseAllLocks(); // release all locks
```

## Viewing locks

<div align="left"><figure><img src="/files/bXkMmp4x4DvYi72yjyjH" alt=""><figcaption><p>Open locks</p></figcaption></figure></div>

The admin page will show any open locks. If anything at all shows up here, it is likely a problem as locks should be only very briefly held.

### Manually releasing locks

Here you can manually release any locks that are held, by clicking the `X` button corresponding to each lock. This can be used to avoid database issues.

{% hint style="warning" %}
Releasing locks can cause data integrity to be compromised! Locks are automatically released when clients close a solution or lose their connection.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/guides/deploy/server-configuration/database-servers/locks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
