Gargi-jais11 commented on code in PR #9773:
URL: https://github.com/apache/ozone/pull/9773#discussion_r2814948568
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMDBCheckpointServletInodeBasedXfer.java:
##########
@@ -410,11 +407,16 @@ private static void cleanupCheckpoint(DBCheckpoint
checkpoint) {
static void writeHardlinkFile(OzoneConfiguration conf, Map<String, String>
hardlinkFileMap,
ArchiveOutputStream<TarArchiveEntry> archiveOutputStream) throws
IOException {
Path data = Files.createTempFile(DATA_PREFIX, DATA_SUFFIX);
- Path metaDirPath = OMStorage.getOmDbDir(conf).toPath();
+ Path metaDirPath = OMStorage.getOmDbDir(conf).toPath()
+ .toAbsolutePath().normalize();
Review Comment:
The temporary file `data` created is never cleaned up. Consider wrapping the
logic around try block and delete the temp file in a finally block. Without
this fix, every checkpoint operation creates an orphned temp file. Over time,
this will consume disk space and could eventually cause the system to run out
of space, leading to operation failures.
```
Path data = Files.createTempFile(DATA_PREFIX, DATA_SUFFIX);
try {
Path metaDirPath = OMStorage.getOmDbDir(conf).toPath()
.toAbsolutePath().normalize();
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : hardlinkFileMap.entrySet()) {
Path p = new File(entry.getKey()).toPath();
if (!p.isAbsolute()) {
p = metaDirPath.resolve(p);
}
p = p.toAbsolutePath().normalize();
String fileId = entry.getValue();
Path relativePath = metaDirPath.relativize(p);
sb.append(relativePath).append('\t').append(fileId).append('\n');
}
Files.write(data, sb.toString().getBytes(StandardCharsets.UTF_8),
StandardOpenOption.TRUNCATE_EXISTING);
includeFile(data.toFile(), OmSnapshotManager.OM_HARDLINK_FILE,
archiveOutputStream);
} finally {
Files.deleteIfExists(data);
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]