What to do if managed transfers fail with BFGIO0341E errors

If a managed transfer is transferring a file into a location that is being monitored by an external process, then it is possible for that managed transfer to fail with the error: BFGIO0341E: The rename of temporary file destination_filename.part to destination_filename failed because the temporary file does not exist. This is due to the way that the destination agent for managed transfers uses temporary files when writing a destination file.

How a destination agent uses temporary files

By default, when a managed file transfer takes place, the destination agent performs 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.partnumber. The destination agent then writes the file data to this file, instead of the one called destination_ filename.part.

If the temporary filename destination_ filename.partnumber already exists, the destination agent tries to create a new temporary file with the name destination_ filename.part(number + 1). If that file already exists, the destination agent attempts to create a temporary file with the name destination_ filename.part(number + 2), and so on until it is successfully able to create the file. In the situation that the agent tries, and fails, to create the temporary file destination_ filename.part1000, it writes directly to the destination file and does not use a temporary file.

When a managed transfer completes, the destination agent deletes all of the temporary files that are called destination_ filename.partnumber, as the assumption is that these were created by the agent during the managed transfer.

Note: If the agent property doNotUseTempOutputFile is set to the value true, the destination agent does not use temporary files. Instead, it writes directly to the destination file. For more information about the doNotUseTempOutputFile property, see The MFT agent.properties file.

Why this problem occurs

A BFGIO0341E error is generated if the destination agent attempts to rename the temporary file, only to find that file is no longer there. A typical scenario that can cause this problem is as follows:
  • 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.

Avoiding this problem

There are two ways to prevent the BFGIO0341E error from occurring:
  • Temporary files written by a destination agent always end with the .part or .partnumber suffix. If you can configure the external process to ignore those files rather than moving them, the files will still exist in the target directory when the destination agent performs the rename operation.
  • Alternatively, configure the destination agent so that it does not use temporary files, and writes directly to the destination file. The destination file is unlocked only when 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. For more information about this property, see The MFT agent.properties file.