# Coordinate concurrent updates

Use transactions and validate concurrency behavior before coordinating workers.

Source: https://particledb.ai/sql/locking/

Use transactions and validate concurrency behavior before coordinating workers.

## Example

```sql
CREATE TABLE docs_locks (id BIGINT PRIMARY KEY, status TEXT);
INSERT INTO docs_locks VALUES (1, 'pending');
```

```sql
BEGIN;
SELECT id, status FROM docs_locks WHERE id = 1 FOR UPDATE;
UPDATE docs_locks SET status = 'running' WHERE id = 1;
COMMIT;
```

## Behavior

A successful `FOR UPDATE` statement alone does not establish a complete queue-claim guarantee. Test behavior with two concurrent connections in your release. Handle transaction conflicts, timeouts and deadlocks through bounded retries. Do not assume `SKIP LOCKED`, advisory locks or `LOCK TABLE` match another database without a specific compatibility check.

## Related

[SQL reference](/sql/overview/) · [Application guide](/guides/relational-data/) · [Troubleshooting](/guides/troubleshooting/)
