From 2ff4a0754472b16e6d67e1ea43190780f7c025f4 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 11 Mar 2026 12:42:18 -0700 Subject: [PATCH] Reduce task logger glog noise and remove per-write fsync (#8603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reduce task logger noise: stop duplicating every log entry to glog and stderr Every task log entry was being tripled: written to the task log file, forwarded to glog (which writes to /tmp by default with no rotation), and echoed to stderr. This caused glog files to fill /tmp on long-running workers. - Remove INFO/DEBUG forwarding to glog (only ERROR/WARNING remain) - Remove stderr echo of every log line - Remove fsync on every single log write (unnecessary for log files) * Fix glog call depth for correct source file attribution The call stack is: caller → Error() → log() → writeLogEntry() → glog.ErrorDepth(), so depth=4 is needed for glog to report the original caller's file and line number. --- weed/worker/tasks/task_logger.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/weed/worker/tasks/task_logger.go b/weed/worker/tasks/task_logger.go index 96f184637..90383c769 100644 --- a/weed/worker/tasks/task_logger.go +++ b/weed/worker/tasks/task_logger.go @@ -317,26 +317,15 @@ func (l *FileTaskLogger) writeLogEntry(entry TaskLogEntry) { return } - // Flush to disk - if err := l.logFile.Sync(); err != nil { - glog.Errorf("Failed to sync log file: %v", err) - } - - // Also log to console and stderr if enabled + // Only forward errors and warnings to glog; routine task logs stay in the task log file. if l.config.EnableConsole { - // Log to glog with proper call depth to show actual source location - // We need depth 3 to skip: writeLogEntry -> log -> Info/Warning/Error calls to reach the original caller formattedMsg := fmt.Sprintf("[TASK-%s] %s: %s", l.taskID, entry.Level, entry.Message) switch entry.Level { case "ERROR": - glog.ErrorDepth(3, formattedMsg) + glog.ErrorDepth(4, formattedMsg) case "WARNING": - glog.WarningDepth(3, formattedMsg) - default: // INFO, DEBUG, etc. - glog.InfoDepth(3, formattedMsg) + glog.WarningDepth(4, formattedMsg) } - // Also log to stderr for immediate visibility - fmt.Fprintf(os.Stderr, "[TASK-%s] %s: %s\n", l.taskID, entry.Level, entry.Message) } }