[PR #13411] [MERGED] Use WriteThrough for ImageSaver #13388

Closed
opened 2025-12-22 09:50:09 +01:00 by backuprepo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/13411
Author: @gnattu
Created: 1/23/2025
Status: Merged
Merged: 1/25/2025
Merged by: @joshuaboniface

Base: release-10.10.zHead: use-writethrough-imagesaver


📝 Commits (1)

  • 644df35 Use WriteThrough for ImageSaver

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 MediaBrowser.Providers/Manager/ImageSaver.cs (+1 -0)

📄 Description

When writing an image to the disk, we use the completion of the async task as a signal indicating the completion of a write operation. However, this approach may not be entirely accurate, as the operating system can optimize IO operations by writing data to an intermediate cache instead of directly to the disk before completing the operation. This optimization can lead to a data race for our scanner, as subsequent tasks such as blurhash computation may attempt to read a file that has not yet been flushed from the volatile cache. Consequently, the data within the file becomes invalid, causing the blurhash computation task to fail.

Use WriteThrough mode to ensure the data is actual on disk before return to resolve this issue.

Changes

Issues

Fixes #3687
If https://github.com/Bond-009/BlurHashSharp/pull/87 is merged and BlurHashSharp get updated, as there is another race condition when multiple threads attempting to open the same image file, but the native open method in skia prevents readonly shares.


🔄 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/jellyfin/jellyfin/pull/13411 **Author:** [@gnattu](https://github.com/gnattu) **Created:** 1/23/2025 **Status:** ✅ Merged **Merged:** 1/25/2025 **Merged by:** [@joshuaboniface](https://github.com/joshuaboniface) **Base:** `release-10.10.z` ← **Head:** `use-writethrough-imagesaver` --- ### 📝 Commits (1) - [`644df35`](https://github.com/jellyfin/jellyfin/commit/644df3585beea7f45f56c0cba9a405a5a73aefe7) Use WriteThrough for ImageSaver ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `MediaBrowser.Providers/Manager/ImageSaver.cs` (+1 -0) </details> ### 📄 Description When writing an image to the disk, we use the completion of the async task as a signal indicating the completion of a write operation. However, this approach may not be entirely accurate, as the operating system can optimize IO operations by writing data to an intermediate cache instead of directly to the disk before completing the operation. This optimization can lead to a data race for our scanner, as subsequent tasks such as blurhash computation may attempt to read a file that has not yet been flushed from the volatile cache. Consequently, the data within the file becomes invalid, causing the blurhash computation task to fail. Use WriteThrough mode to ensure the data is actual on disk before return to resolve this issue. <!-- Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y). For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our documentation. --> **Changes** <!-- Describe your changes here in 1-5 sentences. --> **Issues** <!-- Tag any issues that this PR solves here. ex. Fixes # --> Fixes #3687 If https://github.com/Bond-009/BlurHashSharp/pull/87 is merged and BlurHashSharp get updated, as there is another race condition when multiple threads attempting to open the same image file, but the native open method in skia prevents readonly shares. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
backuprepo 2025-12-22 09:50:09 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#13388
No description provided.