[PR #584] [MERGED] Fix race condition when concurrently downloading packages #628

Closed
opened 2025-12-30 01:25:47 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/584
Author: @bioball
Created: 7/17/2024
Status: Merged
Merged: 7/18/2024
Merged by: @bioball

Base: mainHead: fix-package-download-race-cond


📝 Commits (2)

  • dcdea3c Fix race condition when concurrently downloading packages
  • e3d240a Address PR comments

📊 Changes

2 files changed (+16 additions, -10 deletions)

View changed files

📝 pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java (+10 -5)
📝 pkl-core/src/test/kotlin/org/pkl/core/packages/PackageResolversTest.kt (+6 -5)

📄 Description

This fixes a possible race condition where multiple processes download the same package into the same temp dir.

The issue here is that we are using the same filename when creating these temp files. Because of this, two concurrent processes can possibly run into FileAlreadyExistsException when attempting to create the temporary file.

This fixes the problem by using the Files#createTempFile API to ensure that these filenames are unique.

Closes https://github.com/apple/pkl/issues/583


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/584 **Author:** [@bioball](https://github.com/bioball) **Created:** 7/17/2024 **Status:** ✅ Merged **Merged:** 7/18/2024 **Merged by:** [@bioball](https://github.com/bioball) **Base:** `main` ← **Head:** `fix-package-download-race-cond` --- ### 📝 Commits (2) - [`dcdea3c`](https://github.com/apple/pkl/commit/dcdea3c61710169083baf6afaf245917aa809475) Fix race condition when concurrently downloading packages - [`e3d240a`](https://github.com/apple/pkl/commit/e3d240a00a59cbdd1321ca4adb3e6b50c4d9cb70) Address PR comments ### 📊 Changes **2 files changed** (+16 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java` (+10 -5) 📝 `pkl-core/src/test/kotlin/org/pkl/core/packages/PackageResolversTest.kt` (+6 -5) </details> ### 📄 Description This fixes a possible race condition where multiple processes download the same package into the same temp dir. The issue here is that we are using the _same_ filename when creating these temp files. Because of this, two concurrent processes can possibly run into `FileAlreadyExistsException` when attempting to create the temporary file. This fixes the problem by using the `Files#createTempFile` API to ensure that these filenames are unique. Closes https://github.com/apple/pkl/issues/583 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:25:47 +01:00
adam closed this issue 2025-12-30 01:25:48 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#628