# Re: \[PATCH v3 1/4\] loose: use finite timeout when locking "loose-object-idx" file

- From: Karthik Nayak \<hidden\>
- Date: 2026-10-30 10:43:14 
- List: git
- Page: https://ratatoskr.run/git/2026/10/17832178
- Thread: https://ratatoskr.run/git/2026/10/17790525/t.md

```text
Justin Tobler [ref] writes:

> Loose object index file writers first attempt to acquire a lock via
> `repo_hold_lock_file_for_update_timeout()` and specify a timeout value
> of -1. With a negative timeout value, the lock acquisition retries
> indefinitely while the lockfile still exists. If a process dies while
> holding the lock and leaves a stale lockfile behind, every subsequent
> writer of the mapping file hangs forever instead of reporting an error.
>
> Introduce LOOSE_OBJECT_IDX_LOCK_TIMEOUT_MS to set the timeout to 1000ms
> and use it for all callers that lock a "loose-object-idx" file. A value
> of 1000ms matches the default timeout used for "core.packedRefsTimeout"
> and should provide concurrent writers sufficient time to acquire the
> lock.
>

I was wondering why we don't use a config here too. Seems like Patrick
also mentioned the same in his review. But this is a good middle step
and we can add that in later.

#leftoverbits

[snip]
```

## Attachments

- [signature.asc](https://ratatoskr.run/git/2026/10/17832178/attachment/0) (application/pgp-signature, 690 bytes)
