Skip to content

Commit

Permalink
Fixes issue with file size calculation for existing logs (apache#8971)
Browse files Browse the repository at this point in the history
* Issue arises with existing log files at startup

* Because the existing bytes are not accounted for, log rolling does not occur at the correct time

* Existing code can lead to logging being suspended indefinitely without manual intervention if thresholds are exceeded and no rolled log files can be deleted

* Corner case more evident when other data not rolled by ATS is present in the logging directory
  • Loading branch information
elsloo authored Jul 21, 2022
1 parent fb02ef8 commit 6225b12
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tscore/BaseLogFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ BaseLogFile::open_file(int perm)
}

// set m_bytes_written to force the rolling based on file size.
m_bytes_written = fseek(m_fp, 0, SEEK_CUR);
fseek(m_fp, 0, SEEK_END);
m_bytes_written = ftell(m_fp);

log_log_trace("BaseLogFile %s is now open (fd=%d)\n", m_name.get(), fileno(m_fp));
m_is_init = true;
Expand Down

0 comments on commit 6225b12

Please sign in to comment.