Skip to content

Don't use file locking to protect selfcheck state file #6954

Closed
@chrahunt

Description

@chrahunt

What's the problem this feature will solve?

There are several issues around file locking that have been filed over the years, specifically related to:

  1. Underlying OS/filesystem does not support hardlinks as used by the file lock (Pip Issues on Windows + ReFS #2993, infinite loop after pip install on Android API 24 #5322, pip does not work on Haiku #6761)
  2. Lingering lock files and/or lock files in an inconsistent state can cause pip to hang when attempting to acquire the lock (some of Infinite loop on pip when lockfile can't acquire a lock #3532, Pip locks up after failing to download a package due to network error. #5034)
  3. lockfile uses hostname when creating its unique name, which can result in invalid paths when hostname includes a / (pip hangs, lockfile can't acquire a lock, forward-slash in hostname #6938)

Describe the solution you'd like

  1. Write a selfcheck state file per-prefix, to remove the need to read and then write the file within a lock
  2. Write the file atomically (write to a separate tmp file and then move into place) to avoid partial writes if the process is killed

This will satisfy the linked issues and help us progress on #4766 to remove lockfile entirely.

Alternative Solutions

  1. Switch to MkdirLockFile as currently used in the HTTP cache - the downside of this approach is that it is not backwards-compatible, so we would need to use a separate file to track the information for modern pip versions. If we would need to use a separate file anyway, we might as well go one step further to progress Moving off lockfile #4766.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-lockedOutdated issues that have been locked by automationtype: enhancementImprovements to functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions