Files locked by JVM in pendingMDN folder - OpenAS2 v4.8.2 #528
|
Hi, I am reaching out because we are encountering a file-locking issue after upgrading our environment to OpenAS2 v4.8.2. The Issue
Environment
Has anyone else experienced this with version 4.8.2? Are there any new settings or known bugs regarding file handle management in this release? Any suggestions or patches would be greatly appreciated. |
Replies: 26 comments 14 replies
|
Nobody has reported an y issues like this. |
|
One more thing - do the files that are getting stuck have ".object" extension or no extension? |
|
Hi, I am adding an item; this only happens in the event of a transmission error once all retry attempts have been exhausted.
|
|
Does this happen with all files sent or only the ones that end up in the resender module (this particular example is a file that is being resent via the DirectoryResenderModule thread as indicated in the log message prefix)? The code that controls the creation of the pending file as well as the code that does the cleanup do not open a file handle directly on the cleanup files but instead uses the Apache Commons FileUtils commands. Apaches moveFile actuallly uses a copyfile then delete in your case. This is the Apache method: I have searched on this issue more generally and there do seem to be reported issues using Apache Commons FileUtils when the destination is a Windows network drive. Can you confirm that the file actually does exist in the target network file system: |
|
Please can you confirm that the file actually existed on the file system: From my perspective, this log message is the key to what the real problem is: So in fact the file was not moved because it no longer existed. |
|
We have extracted log for file IT10181220152J$3735919002, which is currently located in the pendingMDN directory. You can find the logs attached below. I have two questions: Was the file successfully copied to the destination folder once the MDN was received? |
|
Here the configuration |
|
There seems to be multiple possible issues going on here so lets try to narrow it down. Prep for the test:
Then run these commands:
Please post the output if there are errors. |
|
|
In your post 5 days ago the error message is: Note that it is using 2 backslash characters for the destination file system: \tesinas01\eint_stor... In your test you only used 1 backslash: \tesinas01\eint_stor... Per Windows documentation, it is supposed to only be a single "". I assume if you use 2 then it will fail to move the file. Can you confirm that the configuration is correct on your OpenAS2 errordir in config.xml? |
|
Ah ok. I will make an debug version that synchronizes the access to the cleanupFiles method in case this is a thread issue with a race condition associated. |
|
Hi Christopher, do you have an update ? regs |
|
Please try the attached jar which synchrniozes access to the cleanup of files and uses the try-with mechanism to ensure streams are closed. Additionally, please set this attribute in your openas2.properties file if you are using it: Otherwise put it in the |
|
NOTE: You must completely remove the old openas2 server jar from your installation otherwise it will continue to use the old one. |
|
OK thank you i perform some test |
|
Hi Christopher, Were you able to reproduce the issue I reported? I would like to perform a test before deploying to production, as it is currently the only environment where the problem persists. regs |
|
Any update on this? |
|
Hey Christopher, we tested your modified version. I'm attaching the logs here. |
|
It looks like the file move is definitely flaky and I need you to run this test file attached to see if we can get it to fail. Prep for the test: Then run this command a few times (replacing [destination directory on the network file system] with a valid network directory:
If there are any errors reported then run this command a few times: You will have to delete the files it creates in the destination network file system before re-running the test. Let me know if there are errors. |
|
Any luck with this? |
|
Hi, I executed the test and received no errors. There are 100 files of 1 KB each in the destination folder. Regs |
|
Unless I can reproduce this issue, I am unclear how to resolve it. For now I will add a retry loop in the move method that will sleep for a configurable amount of time then retry once if there is a failure. If you can figure out a way to make the error happen consistently then I could work on a fix but for now that seems the best I can come up with. I will release the adjusted algorithm for the move in the next day or so. |
|
@claudiodegioannibme - having thought a lot more about this, it does not make sense to retry since the file is locked by something and per your feedback, it requires a restart to unlock it. I am now thinking that perhaps the initial calls to the atomic move method (uses Java NIO) before trying the Apaches move method is somehow locking the file. So I have created another test class that has a copy of the full moveFile method implemented in org.openas2.IOUtil but with the logging removed to see if calling that method a significant number of times will produce the error. This is the new file: Please run the same way as previously. If you do eventually get an error then try running it with the additional "true" command line parameter which will use a more "intelligent" method that tries to pick the right move mechanism based on the file system types and file system proders of the source and destination. |
|
Hi, |
|
Ok - I have run out of ideas on how to identify the underlying problem at this point. For the v5 release, the retry process has been significantly rewritten and the number of files tracked has been reduced and should result in a more reliable and debuggable process. |
|
Ok I try the 4.8.3 |


In your post 5 days ago the error message is:
2026-05-07 10:16:34.378 [DirectoryResenderModule] ERROR org.openas2.util.AS2Util - Error moving file to \\tesinas01\eint_stor\gruppotesi\datasite\orxt\ds_dati\culina\error_prod\ : Failed to delete original file 'D:\OpenAS2v2\OpenAS2\.\config\..\data\pendingMDN3\07052026094443+0200-4bd484d4-ed52-4bb7-a453-d0dce003aa29@ALDI_UK_A$3735739227' after copy to '\\tesinas01\eint_stor\gruppotesi\datasite\orxt\ds_dati\culina\error_prod\07052026094443+0200-4bd484d4-ed52-4bb7-a453-d0dce003aa29@ALDI_UK_A$3735739227'Note that it is using 2 backslash characters for the destination file system: \tesinas01\eint_stor...
In your test you only used 1 backslash: \…