Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.21.0
-
None
-
CentOS server, Java 11
Description
Problem happens when a PutFTP is set to run several concurrent tasks and two (or more ) FlowFiles come in and both need to create the same directory. One of them will create directory and succeed immediately while the other will try to create directory, but fail since it already exist, throw an error, the FlowFile will then be penalized and on second run will succeed.
While it is not the biggest error, as files are getting transferred in the end, but the bulletins and errors are annoying, especially in production environment where you don't want to get unnecessary errors.
We found that the solution involves a simple change to the FTPTransfer.java class in:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/FTPTransfer.java
On line 398 and ensureDirectoryExists method you can simply add another if check which double checks that the directory exists when it fails to create one.
final boolean cdSuccessful = setWorkingDirectory(remoteDirectory); if (!cdSuccessful) { if (client.makeDirectory(remoteDirectory)) { logger.debug("Remote Directory not found: created directory [{}]", remoteDirectory); } else if (!setWorkingDirectory(remoteDirectory)) { // Double check that the dir exists as it might have been created in another thread throw new IOException("Failed to create remote directory " + remoteDirectory); } }
We have created a fix and will submit it as a Pull Request on GitHub
Attachments
Issue Links
- links to