hongzhi-gao opened a new pull request, #18114:
URL: https://github.com/apache/iotdb/pull/18114
## Description
### Problem
During datanode removal, multiple DataRegions may concurrently migrate
snapshots to the same target node. All snapshot staging directories share one
root (`data/datanode/data/snapshot/`). While one region is receiving snapshots,
`getNextFolder()` walks this shared root to compute occupied space; if another
region deletes its staging subdirectory at the same time, `Files.walk` throws
`NoSuchFileException`. This was misinterpreted as "folder full" → node switched
to read-only (`DISK_FULL`) → snapshot transmission failed → region migration /
datanode removal blocked.
### Fix
1. **`JVMCommonUtils.getOccupiedSpace`**: Replace `Files.walk` with
`walkFileTree`; return `CONTINUE` in `visitFileFailed` to ignore entries
deleted during traversal.
2. **`MinFolderOccupiedSpaceFirstStrategy`**: On refresh failure, keep the
previous cached occupied space instead of setting `Long.MAX_VALUE`.
3. **`FolderManager`**: Only switch to read-only when no healthy folder has
available disk space (`hasSpace()`), not merely when folder selection fails.
### Tests
- `JVMCommonUtilsTest.getOccupiedSpaceIgnoresConcurrentlyDeletedEntries`
-
`MinFolderOccupiedSpaceFirstStrategyRealFsTest.getNextFolderDoesNotEnterReadOnlyWhenDiskHasSpace`
<hr>
This PR has:
- [x] been self-reviewed.
- [x] concurrent read
- [ ] concurrent write
- [ ] concurrent read and write
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods.
- [ ] added or updated version, __license__, or notice information
- [x] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [x] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for code coverage.
- [ ] added integration tests.
- [ ] been tested in a test IoTDB cluster.
<hr>
##### Key changed/added classes (or packages if there are too many classes)
in this PR
- `org.apache.iotdb.commons.utils.JVMCommonUtils`
-
`org.apache.iotdb.commons.disk.strategy.MinFolderOccupiedSpaceFirstStrategy`
- `org.apache.iotdb.commons.disk.FolderManager`
- `org.apache.iotdb.commons.i18n.UtilMessages`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]