Skip to content

Conversation

@sadanand48
Copy link
Contributor

What changes were proposed in this pull request?

Because of fixes in HDDS-13905 an entire BG service task would be blocked because of bootstrap operation running on a leader OM. One possible improvement here would be to just to create a hardlink(which we already do to ensure this file doesn't get deleted by rocksdb operations but we also write the file into the Tarball stream synchronously

public static long linkAndIncludeFile(File file, String entryName,
ArchiveOutputStream<TarArchiveEntry> archiveOutput, Path tmpDir) throws IOException {
File link = tmpDir.resolve(entryName).toFile();
long bytes = 0;
try {
Files.createLink(link.toPath(), file.toPath());
TarArchiveEntry entry = archiveOutput.createArchiveEntry(link, entryName);
archiveOutput.putArchiveEntry(entry);
try (InputStream input = Files.newInputStream(link.toPath())) {
bytes = IOUtils.copyLarge(input, archiveOutput);
}
archiveOutput.closeArchiveEntry();
} catch (IOException ioe) {
LOG.error("Couldn't create hardlink for file {} while including it in tarball.",
file.getAbsolutePath(), ioe);
throw ioe;
} finally {
Files.deleteIfExists(link.toPath());
}
return bytes;
}
) to the file to be copied into tar outputStream into a tmp directory under the bootstrap lock and write all the entries corresponding to the link created outside the lock(The entry should also include the hardLinkFile created in the last batch).

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-13906

How was this patch tested?

Will add tests

@swamirishi swamirishi self-requested a review January 5, 2026 14:11
Copy link
Contributor

@swamirishi swamirishi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch @sadanand48 . Have a few doubts with the implementation

Files.deleteIfExists(link.toPath());
}
}
writeHardlinkFile(conf, hardLinkFileMap, archiveOutput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be writing the hardLinkFile in all iterations

path = getDbStore().getDbLocation().toPath().resolve(dbFile.getFileName()).toAbsolutePath().toString();
}
hardLinkFileMap.put(path, fileId);
omdbArchiver.getHardLinkFileMap().put(path, fileId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have this logic inside recordFileEntry

@sadanand48 sadanand48 added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Jan 5, 2026
@swamirishi
Copy link
Contributor

@rnblough Do you wanna take a look at this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot https://issues.apache.org/jira/browse/HDDS-6517

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants