From ce7260b80756b1328321f935a63fc93d09a459d9 Mon Sep 17 00:00:00 2001 From: Hao Chang Yu Date: Thu, 26 Nov 2026 14:18:03 +1000 Subject: [PATCH] Ignore FileNotFoundError when unlinking temp artifact During concurrent On Demand downloads, pre_save() may move the temp file to storage before a concurrent DB commit triggers IntegrityError. Suppress FileNotFoundError on os.unlink() so the response completes cleanly instead of aborting the transfer. Closes #8383 (cherry picked from commit 7eff85689a5fcf41a25558d30f6237bf25a05fc8) --- CHANGES/8383.bugfix | 1 + pulpcore/content/handler.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 CHANGES/8383.bugfix diff --git a/CHANGES/8383.bugfix b/CHANGES/8383.bugfix new file mode 100644 index 00000000000..6c6549dbf24 --- /dev/null +++ b/CHANGES/8383.bugfix @@ -0,0 +1 @@ +Fixed a race condition during concurrent on-demand downloads where unlinking an already-moved temporary artifact raised FileNotFoundError and aborted client transfers. diff --git a/pulpcore/content/handler.py b/pulpcore/content/handler.py index 73ea2b2f4a8..301cf2a79c0 100644 --- a/pulpcore/content/handler.py +++ b/pulpcore/content/handler.py @@ -894,7 +894,11 @@ def _save_artifact(self, download_result, remote_artifact, request=None): # The file needs to be unlinked because it was not used to create an artifact. # The artifact must have already been saved while servicing another request for # the same artifact. - os.unlink(download_result.path) + try: + os.unlink(download_result.path) + except FileNotFoundError: + # Temp file may already be moved to storage before the IntegrityError + pass if content_artifact._state.adding: # This is the first time pull-through content was requested.