Skip to content

check hostname in is_lock_held_by_us - #553

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:soft-held-by-us-hostname
Jun 8, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
dxbjavid:soft-held-by-us-hostname

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

is_lock_held_by_us compares only the pid from the lock file against os.getpid() and ignores the hostname stored alongside it, so on a shared filesystem where the same pid is live on two hosts a lock genuinely held by another node is reported as held by us, and a caller acting on that by releasing or breaking it can drop a lock another host still holds. the lock file already records the hostname for exactly this disambiguation and the stale-break path checks it, so this reads the holder through _parse_lock_holder and requires both the pid and the hostname to match before returning true. added a regression case to the existing is_lock_held_by_us parametrisation covering a same-pid, different-host file.

the lock file stores the holder's hostname so pid checks stay scoped to one host; on a shared filesystem two hosts can run the same pid, so matching the pid alone reported another host's lock as held by us. require the hostname to match too.

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaborbernat
gaborbernat merged commit 2ff7c3c into tox-dev:main Jun 8, 2026
32 checks passed
@dxbjavid

dxbjavid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge! Appreciated

ozeranskii pushed a commit to tempusbuild/runner-images that referenced this pull request Jun 10, 2026
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [filelock](https://redirect.github.com/tox-dev/py-filelock) |
`==3.29.1` → `==3.29.2` |
![age](https://developer.mend.io/api/mc/badges/age/pypi/filelock/3.29.2?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/filelock/3.29.1/3.29.2?slim=true)
|

---

### Release Notes

<details>
<summary>tox-dev/py-filelock (filelock)</summary>

###
[`v3.29.2`](https://redirect.github.com/tox-dev/filelock/releases/tag/3.29.2)

[Compare
Source](https://redirect.github.com/tox-dev/py-filelock/compare/3.29.1...3.29.2)

<!-- Release notes generated using configuration in .github/release.yaml
at 3.29.2 -->

#### What's Changed

- open marker reads non-blocking to refuse attacker-placed fifo by
[@&#8203;dxbjavid](https://redirect.github.com/dxbjavid) in
[tox-dev/filelock#549](https://redirect.github.com/tox-dev/filelock/pull/549)
- 🔒 fix(soft): harden stale-lock breaking and self-heal malformed locks
by [@&#8203;gaborbernat](https://redirect.github.com/gaborbernat) in
[tox-dev/filelock#551](https://redirect.github.com/tox-dev/filelock/pull/551)
- check hostname in is\_lock\_held\_by\_us by
[@&#8203;dxbjavid](https://redirect.github.com/dxbjavid) in
[tox-dev/filelock#553](https://redirect.github.com/tox-dev/filelock/pull/553)

**Full Changelog**:
<tox-dev/filelock@3.29.1...3.29.2>

</details>

---

### Configuration

📅 **Schedule**: (in timezone Etc/UTC)

- Branch creation
  - "before 6am on monday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/tempusbuild/runner-images).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMDkuNCIsInVwZGF0ZWRJblZlciI6IjQzLjIwOS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants