Something that crops up in PMRs every so often is customers reporting that managed transfers fail, with one or more transfer items in the managed transfer reporting the error:
BFGIO0341E: The rename of temporary file <destination filename>.part to <destination filename> failed because the temporary file does not exist.
In this blog post, we'll look at why this error can occur, and how to prevent it.
How a Destination Agent uses temporary files
By default, when a managed file transfer takes place, the Destination Agent will perform the following steps:
- Create a temporary file, called <destination filename>.part.
- Lock the temporary file.
- Write file data into the temporary file, when it is received from the Source Agent.
- Unlock the temporary file after all of the file data has been received and written out.
- Rename the temporary file, from <destination filename>.part. to <destination filename>.
If a managed transfer goes into recovery, then it is possible for the Destination Agent to create temporary files called <destination filename>.part<number>. The Destination Agent will then write the file data to this file instead of the one called <destination filename>.part.
Why a BFGIO0341E error can occur.
A BFGIO0341E error will be generated if the Destination Agent attempted to rename the temporary file, only to find that that file is no longer there. Here is the typical scenario that can cause this:
- A "staging directory" has been set up on the target file system.
- An external process is configured to monitor the "staging directory" , and move any files that it finds to a new location.
- The Destination Agent creates and locks the temporary file <destination filename>.part in the "staging directory".
- The Destination Agent writes file data into the temporary file.
- After all of the file data has been written to the temporary file, the Destination Agent unlocks the file.
- The external process finds the temporary file, and moves it to the new location.
- The Destination Agent attempts to rename the temporary file, and finds that it is no longer there. As a result, the transfer item is marked as "Failed" with a BFGIO0341E error.
How to prevent the error from happening
There are two ways to prevent the BFGIO0341E error from occurring:
- Temporary files written by a Destination Agent always end with the .part or .part<number> suffix. If the external process can be configured to ignore those files rather than moving them, then the files will still exist in the target directory when the Destination Agent performs the rename operation.
- An alternative approach would be to configure the Destination Agent so that it does not use temporary files, and writes directly to the destination file. The destination file will only be unlocked once all of the file data has been written to it, at which point it can be picked up by the external process. To configure the Destination Agent to write directly to the destination file, set the agent property doNotUseTempOutputFile=true. More information about this property can be found in the The agent.properties file topic in the MQ sections of IBM Knowledge Center.
I hope this has given you some insight into how a Destination Agent uses temporary files, and why the BFGIO0341E error can occur. If you have any questions, feel free to ask them as comments to this post, and I'll be happy to answer them.