[AMQ-9856] Journal move fails on Windows#1654
Conversation
|
FYI, here is the stack trace on Windows |
|
A debug on macos confirmed that when the move is requested, the db-6.log file is not opened by the Java process. Note: This may be a race condition if close is async. |
|
The exception is wrapped and the original exception and stacktrace is lost-- I made a quick change to see if we can get the full stacktrace ref: #1655 |
|
@mattrpav Ok with you to merge? |
There was a problem hiding this comment.
Pull request overview
This pull request addresses Windows file locking issues (AMQ-9856) in journal operations by introducing non-blocking file operations with asynchronous cleanup mechanisms. The changes replace direct file system operations with IOHelper utility methods that gracefully handle Windows' exclusive file locking behavior, where files cannot be moved or deleted while open by another process.
Changes:
- Introduced async file deletion mechanism with a background cleanup thread for Windows
- Added renameFile and moveFile methods with fallback strategies (rename → NIO move → copy+delete)
- Migrated DataFile, PageFile, and LockFile to use non-blocking IOHelper methods instead of direct File operations
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java | Added async cleanup infrastructure with ScheduledExecutorService, implemented deleteFileNonBlocking, renameFile, and enhanced moveFile with multi-strategy fallback approach |
| activemq-broker/src/test/java/org/apache/activemq/util/IOHelperTest.java | New test suite covering moveFile, deleteFileNonBlocking, and isWindows utility method |
| activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java | Updated delete and archive methods to use IOHelper utilities, fixing error message bug in archive |
| activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/journal/DataFile.java | Migrated delete method to use IOHelper.deleteFileNonBlocking |
| activemq-broker/src/main/java/org/apache/activemq/util/LockFile.java | Updated unlock method to use non-blocking deletion |
| activemq-kahadb-store/pom.xml | Whitespace cleanup (trailing space removal) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
Outdated
Show resolved
Hide resolved
activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
Outdated
Show resolved
Hide resolved
activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
Outdated
Show resolved
Hide resolved
activemq-broker/src/test/java/org/apache/activemq/util/IOHelperTest.java
Show resolved
Hide resolved
activemq-broker/src/main/java/org/apache/activemq/util/IOHelper.java
Outdated
Show resolved
Hide resolved
7d63f1e to
9e8410e
Compare
To be discussed. On Github Actions for Windows nodes, it consistently fails.
On Windows, files cannot be renamed/moved while open by another process. The simplest and most appropriate fix is to skip this test on Windows where file locking makes it inherently unreliable.