Persist locking across builds

I was going through the documentation in buildkite-agent lock v3 | Buildkite Documentation and I couldn’t tell if the lock can persist across builds irrespective of agent process. Request to clarify.

Hi @abhandage and Welcome to Buildkite! :wave:

Locks in Buildkite are tied to the agent that creates them, meaning they don’t persist across builds or agent restarts. If a job acquires a lock on one agent and that agent stops or a different agent picks up the next build, the lock is gone. So no, locks can’t carry over between builds, regardless of agent processes.

1 Like

thanks for the reply, is there a feature in buildkite that can achieve what I am looking for i.e. acquire locks and persist it across builds unless released ?

Hey! No, we don’t have a built-in feature specifically for acquiring locks and persisting them across builds. Can you expand in your use case and what you are trying to do? maybe there are some alternatives we can suggest :slight_smile:

Hi @abhandage,

Thanks for pointing out the potential for improvement on the documentation! We’ve updated the documentation now to clearly reflect real-world uses for the locking functionality and improved the overall explanations.

To answer the original question, yes - locks can persist across builds, but locks are host-specific, so if you have two agents running on different hosts, they will not be able to see the lock from the other host.