Skip to content

Commit

Permalink
fix(tlog): close tlog writer to prevent fd leak (aws-greengrass#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahadmohammed01 authored Apr 8, 2021
1 parent 87d89a6 commit 64f066c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ private synchronized void truncateTlog() {
if (out instanceof Commitable) {
((Commitable) out).commit();
}
logger.atDebug(TRUNCATE_TLOG_EVENT).log("existing tlog writer closed");

// move old tlog
try {
out.close();
logger.atDebug(TRUNCATE_TLOG_EVENT).log("existing tlog writer closed");
Files.move(tlogOutputPath, oldTlogPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
logger.atError(TRUNCATE_TLOG_EVENT, e).log("failed to rename existing tlog");
Expand Down

0 comments on commit 64f066c

Please sign in to comment.