Skip to content

Conversation

@ericcarlschwartz
Copy link
Contributor

@ericcarlschwartz ericcarlschwartz commented Oct 11, 2019

this addresses issue #4635

if you'd like to test and let me know if you like this @ema feel free

also reuses existing pipes so we don't just create a new one for every reload as discussed with @ema and @SolidWallOfCode at the summit

@ericcarlschwartz
Copy link
Contributor Author

let me know what i can do to address build issues if anything

// reuse existing pipe if available
struct stat stat_p;
stat(m_name, &stat_p);
if (S_ISREG(stat_p.st_mode) && S_ISFIFO(stat_p.st_mode)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How can a file be a regular file and a fifo?

@bryancall bryancall changed the title address pipe remove on reload and add pipe reuse Address pipe remove on reload and add pipe reuse Oct 16, 2019
@zwoop
Copy link
Contributor

zwoop commented Oct 21, 2019

This needs to go to 9.0.0 presumably ?

@zwoop zwoop mentioned this pull request Oct 22, 2019
44 tasks
@SolidWallOfCode
Copy link
Member

Eric's moved on, we'll probably need to close this out since it's not going to get fixed. @bneradt is working on this now.

@ericcarlschwartz
Copy link
Contributor Author

ericcarlschwartz commented Oct 22, 2019 via email

@bneradt
Copy link
Contributor

bneradt commented Oct 22, 2019

I've reproduced what @ema described with his excellent description in issue 4635.

I applied @ericcarlschwartz 's change from this PR (using '||' instead of '&&' per Bryan's comment), and indeed it addresses the majority of Emanuele's issues. However, I notice that traffic_server still seems to be leaking the file descriptors with each -HUP against traffic_manager:

$ lsof test_all_headers.pipe 
COMMAND     PID    USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
[TS_MAIN] 26124 bneradt   53w  FIFO  252,2      0t0 314977783 test_all_headers.pipe
[TS_MAIN] 26124 bneradt   55w  FIFO  252,2      0t0 314977783 test_all_headers.pipe
[TS_MAIN] 26124 bneradt   56w  FIFO  252,2      0t0 314977783 test_all_headers.pipe
cat       27085 bneradt    3r  FIFO  252,2      0t0 314977783 test_all_headers.pipe

I'll look into what can be tweaked to address the leak.

@bneradt
Copy link
Contributor

bneradt commented Oct 22, 2019

Digging through LogObject.cc, this patch (added on top of Eric's) cleans up the leaked file descriptors:

$ git diff
diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index 0a0bc9f..8752561 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -181,6 +181,8 @@ LogObject::~LogObject()
     if (m_host_list.count()) {
       m_host_list.clear();
     }
+  } else {
+    m_logFile->close_file();
   }
   ats_free(m_basename);
   ats_free(m_filename);

roll_file = false;
} else {
if (S_ISFIFO(s.st_mode)) {
unlink(filename);
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing this out locally, removing the unlink seems to get the behavior that addresses the concerns @ema raised.

However, do we have to worry about the comment at line 974:
https://github.com/apache/trafficserver/pull/6017/files#diff-75bc20fd8082b64381dec2cf402275feR974

It seems to indicate that the unlink is intentional so that the metadata is correct. Maybe the comment is incorrect though?

Copy link
Contributor

Choose a reason for hiding this comment

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

what does the meta data files say about the fifo in your testing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Reading through the code, I see that the meta file is only used for log rolling which is not applicable to pipes. We don't even instantiate a BaseLogFile (which creates and maintains the meta file) for pipes:

LogFile::LogFile(const char *name, const char *header, LogFileFormat format, uint64_t signature, size_t ascii_buffer_size,
                 size_t max_line_size)
  : m_file_format(format),
    m_name(ats_strdup(name)),
    m_header(ats_strdup(header)),
    m_signature(signature),
    m_max_line_size(max_line_size)
{
  if (m_file_format != LOG_FILE_PIPE) {    <<<<<<<< Note created for pipes.
    m_log = new BaseLogFile(name, m_signature);
    m_log->set_hostname(Machine::instance()->hostname);
  } else {
    m_log = nullptr;
  }

In any case, the comment about unlinking the pipe to maintain the metadata for it seems to be a mistaken comment (assuming by metadata the author meant the meta file).

@ericcarlschwartz : I'll create a new PR with the close() call and manage the PR from there.

Thanks!
Brian

@shinrich
Copy link
Member

Issue was addressed in PR #6076. Closing this PR.

@shinrich shinrich closed this Nov 14, 2019
@zwoop zwoop removed this from the 10.0.0 milestone Nov 18, 2019
@zwoop
Copy link
Contributor

zwoop commented Nov 18, 2019

Remember to remove Project / Milestone etc. on closed PRs.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants