You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by us...@apache.org on 2014/01/26 17:35:18 UTC

git commit: TS-1606: Log buffers are not flushed periodically when TS is launched with NO_REMOTE_MANAGEMENT flag

Updated Branches:
  refs/heads/master 0f4c7b8ff -> 6215bf9e9


TS-1606: Log buffers are not flushed periodically when TS is launched with NO_REMOTE_MANAGEMENT flag

Also fix wrong check in Log::flush_thread_main. Credit to Yakov Markovitch <ym...@gmail.com> for
pinpointing the problem.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/6215bf9e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/6215bf9e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/6215bf9e

Branch: refs/heads/master
Commit: 6215bf9e9dc3bf21f9507ce6856891e8168331c2
Parents: 0f4c7b8
Author: Uri Shachar <us...@apache.org>
Authored: Sun Jan 26 18:13:01 2014 +0200
Committer: Uri Shachar <us...@apache.org>
Committed: Sun Jan 26 18:13:01 2014 +0200

----------------------------------------------------------------------
 CHANGES              |  3 ++
 proxy/logging/Log.cc | 79 ++++++++++++++++++-----------------------------
 proxy/logging/Log.h  |  4 +--
 3 files changed, 34 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6215bf9e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7d24d27..81e8e6e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-1606] Log buffers are not flushed periodically when TS is launched 
+   with NO_REMOTE_MANAGEMENT flag
+
   *) [TS-2481] Incorrect origin server port used sometimes (with keep-alive).
    Author: Dimitry Andric <di...@andric.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6215bf9e/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 6f326c9..ebf0233 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -938,15 +938,6 @@ Log::init(int flags)
     REC_RegisterConfigUpdateFunc("proxy.local.log.collation_mode",
                                  &Log::handle_logging_mode_change, NULL);
 
-    // we must create the flush thread since it takes care of the
-    // periodic events (should this behavior be reversed ?)
-    //
-    create_threads();
-
-    eventProcessor.schedule_every(NEW (new PeriodicWakeup(collation_preproc_threads, 1)),
-                                  HRTIME_SECOND, ET_CALL);
-    init_status |= PERIODIC_WAKEUP_SCHEDULED;
-
     // Clear any stat values that need to be reset on startup
     //
     RecSetRawStatSum(log_rsb, log_stat_log_files_open_stat, 0);
@@ -997,13 +988,9 @@ Log::init_when_enabled()
                         Log::config->rolling_size_mb));
 
     // create the flush thread and the collation thread
-    //
     create_threads();
-
-    // schedule periodic wakeup
-    // ToDo: Why was this removed??
-    //
-    //      eventProcessor.schedule_every (NEW (new PeriodicWakeup()), HRTIME_SECOND, ET_CALL);
+    eventProcessor.schedule_every(NEW (new PeriodicWakeup(collation_preproc_threads, 1)),
+                                  HRTIME_SECOND, ET_CALL);
 
     init_status |= FULLY_INITIALIZED;
   }
@@ -1017,39 +1004,35 @@ Log::init_when_enabled()
 void
 Log::create_threads()
 {
-  if (!(init_status & THREADS_CREATED)) {
-
-    char desc[64];
-    preproc_notify = new EventNotify[collation_preproc_threads];
+  char desc[64];
+  preproc_notify = new EventNotify[collation_preproc_threads];
 
-    size_t stacksize;
-    REC_ReadConfigInteger(stacksize, "proxy.config.thread.default.stacksize");
+  size_t stacksize;
+  REC_ReadConfigInteger(stacksize, "proxy.config.thread.default.stacksize");
 
-    // start the preproc threads
-    //
-    // no need for the conditional var since it will be relying on
-    // on the event system.
-    for (int i = 0; i < collation_preproc_threads; i++) {
-      Continuation *preproc_cont = NEW(new LoggingPreprocContinuation(i));
-      sprintf(desc, "[LOG_PREPROC %d]", i);
-      eventProcessor.spawn_thread(preproc_cont, desc, stacksize);
-    }
+  // start the preproc threads
+  //
+  // no need for the conditional var since it will be relying on
+  // on the event system.
+  for (int i = 0; i < collation_preproc_threads; i++) {
+    Continuation *preproc_cont = NEW(new LoggingPreprocContinuation(i));
+    sprintf(desc, "[LOG_PREPROC %d]", i);
+    eventProcessor.spawn_thread(preproc_cont, desc, stacksize);
+  }
 
-    // Now, only one flush thread is supported.
-    // TODO: Enable multiple flush threads, such as
-    //       one flush thread per file.
-    //
-    flush_notify = new EventNotify;
-    flush_data_list = new InkAtomicList;
+  // Now, only one flush thread is supported.
+  // TODO: Enable multiple flush threads, such as
+  //       one flush thread per file.
+  //
+  flush_notify = new EventNotify;
+  flush_data_list = new InkAtomicList;
 
-    sprintf(desc, "Logging flush buffer list");
-    ink_atomiclist_init(flush_data_list, desc, 0);
-    Continuation *flush_cont = NEW(new LoggingFlushContinuation(0));
-    sprintf(desc, "[LOG_FLUSH]");
-    eventProcessor.spawn_thread(flush_cont, desc, stacksize);
+  sprintf(desc, "Logging flush buffer list");
+  ink_atomiclist_init(flush_data_list, desc, 0);
+  Continuation *flush_cont = NEW(new LoggingFlushContinuation(0));
+  sprintf(desc, "[LOG_FLUSH]");
+  eventProcessor.spawn_thread(flush_cont, desc, stacksize);
 
-    init_status |= THREADS_CREATED;
-  }
 }
 
 /*-------------------------------------------------------------------------
@@ -1323,12 +1306,10 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
     // Time to work on periodic events??
     //
     now = ink_get_hrtime() / HRTIME_SECOND;
-    if (now > last_time) {
-      if ((now % (PERIODIC_TASKS_INTERVAL)) == 0) {
-        Debug("log-preproc", "periodic tasks for %" PRId64, (int64_t)now);
-        periodic_tasks(now);
-      }
-      last_time = (now = ink_get_hrtime() / HRTIME_SECOND);
+    if (now >= last_time + PERIODIC_TASKS_INTERVAL) {
+      Debug("log-preproc", "periodic tasks for %" PRId64, (int64_t)now);
+      periodic_tasks(now);
+      last_time = ink_get_hrtime() / HRTIME_SECOND;
     }
 
     // wait for more work; a spurious wake-up is ok since we'll just

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6215bf9e/proxy/logging/Log.h
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.h b/proxy/logging/Log.h
index 92c4525..843c1d3 100644
--- a/proxy/logging/Log.h
+++ b/proxy/logging/Log.h
@@ -374,9 +374,7 @@ public:
   enum InitFlags
   {
     FIELDS_INITIALIZED = 1,
-    THREADS_CREATED = 2,
-    PERIODIC_WAKEUP_SCHEDULED = 4,
-    FULLY_INITIALIZED = 8
+    FULLY_INITIALIZED = 2
   };
 
   enum ConfigFlags