---
id: flow--lock-plugin
title: "Lock"
summary: "Lets only one record at a time pass through to the components behind it. Use it when concurrent requests (for example several HTTP calls, Fork tasks or a parallel For each) must not run a section of the flow at the same time, such as updating a shared file or a counter."
audience: user
keywords: "input, output"
---
# Lock

Lets only one record at a time pass through to the components behind it. Use it when concurrent requests (for example several HTTP calls, Fork tasks or a parallel For each) must not run a section of the flow at the same time, such as updating a shared file or a counter.

## Pins

| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | any | Records entering the locked section. |
| Output | output | same as input | The unchanged record; the components connected here run under the lock. |

## Configuration

None besides the common settings.

## Behaviour

- Each record waits until no other record is inside the locked section, then it is sent to `Output`. The lock is held until the downstream processing of that record returns; then the next waiting record enters.
- The lock belongs to this component instance in this flow: two Lock components do not block each other, and other flows (or other instances of the flow) are not affected.
- Records are not dropped; they wait without a timeout.

## Notes

- Only synchronous downstream work is protected. Anything handed to a background task inside the section (for example a Fork) leaves the lock immediately.
- Keep the locked section short: every waiting record blocks a thread. A slow or hanging component behind the lock stalls all callers.
- Do not route a record back into the same Lock from inside the locked section (the same thread re-enters, so it is not blocked, but the section is then not exclusive).

## Example

Http listener → **Lock** → File writer (append) → Http response
