Limits on retrying FileStore writes without duplicate data
0 reputation · 17 Aug 2020, 22:04 UTC
0 reputation · 17 Aug 2020, 22:04 UTC
The org.eclipse.core.filesystem.FileStore API provides a putInfo method for writing data, but it does not expose any retry mechanism. When a write fails, a CoreException is thrown and the caller must decide how to recover. The API also offers no flag or contract that guarantees idempotency; if a retry is performed, the caller must manually ensure that duplicate data is not written.
In addition, the Job API can schedule background tasks that might be retried, and IResourceChangeListener events can detect failed writes, yet neither mechanism provides automatic duplicate suppression. Developers are left to implement their own idempotent logic.
Given this design, the following questions remain:
FileStore writes?putInfo or the Job API to prevent duplicate writes on retry?35275 reputation · 18 Aug 2020, 01:42 UTC
There are no built-in flags or parameters in the org.eclipse.core.filesystem.FileStore API or the Eclipse Job API that automatically suppress duplicate data during retries. Because FileStore is a generic abstraction for diverse file systems (local, remote, or custom EFS providers), the platform does not enforce a global idempotency contract. Responsibility for preventing duplicate data rests entirely with the caller.
The FileStore API is designed to remain portable across heterogeneous backends. Since different file system providers offer varying levels of atomicity and support for operations like appending or truncating, implementing a universal "retry-safe" write would require the platform to make assumptions that might not hold true for all providers. By leaving recovery to the developer, the API avoids introducing inconsistent behavior across different environments.
To ensure that retrying a failed write does not result in corrupted or duplicated data, use one of the following patterns:
IFileStore.move with the EFS.OVERWRITE option to rename the temporary file to the target destination. If the process fails and is retried, the temporary file is simply overwritten, and the target file only changes once the move succeeds.openOutputStream, ensure you are not using EFS.APPEND unless you have a mechanism to track exactly how many bytes were written before the CoreException occurred. For most cases, rewriting the entire file from the start is the safest way to ensure idempotency.Before deploying a retry loop, verify the behavior of your specific EFS provider with the following steps:
Note: putInfo is used for modifying file attributes (metadata), not for writing file content. Ensure your retry logic targets openOutputStream or IFile.setContents for data operations.
To provide a more specific recommendation, could you clarify if you are targeting a local file system or a remote provider (e.g., SSH/FTP)?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.