|
|
803fb7 |
From c87355bc80da9e2cba7f7723d7c6568dfa56f1a1 Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: Vito Caputo <vito.caputo@coreos.com>
|
|
|
803fb7 |
Date: Fri, 8 Jan 2016 12:11:44 -0800
|
|
|
803fb7 |
Subject: [PATCH] journal: normalize priority of logging sources
|
|
|
803fb7 |
|
|
|
803fb7 |
The stream event source has a priority of SD_EVENT_PRIORITY_NORMAL+5,
|
|
|
803fb7 |
and stdout source +10, but the native and syslog event sources are left
|
|
|
803fb7 |
at the default of 0.
|
|
|
803fb7 |
|
|
|
803fb7 |
As a result, any heavy native or syslog logger can cause starvation of
|
|
|
803fb7 |
the other loggers. This is trivially demonstrated by running:
|
|
|
803fb7 |
|
|
|
803fb7 |
dd if=/dev/urandom bs=8k | od | systemd-cat & # native spammer
|
|
|
803fb7 |
systemd-run echo hello & # stream logger
|
|
|
803fb7 |
journalctl --follow --output=verbose --no-pager --identifier=echo &
|
|
|
803fb7 |
|
|
|
803fb7 |
... and wait, and wait, the "hello" never comes.
|
|
|
803fb7 |
|
|
|
803fb7 |
Now kill %1, "hello" arrives finally.
|
|
|
803fb7 |
|
|
|
803fb7 |
Cherry-picked from: 48cef29504b1ffc0df9929f2d8b2af2ad74d2b4a
|
|
|
803fb7 |
Related: #1318994
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/journal/journald-native.c | 4 ++++
|
|
|
803fb7 |
src/journal/journald-stream.c | 2 +-
|
|
|
803fb7 |
src/journal/journald-syslog.c | 4 ++++
|
|
|
803fb7 |
3 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
|
|
|
803fb7 |
index 851625de0..2c9cf6e7a 100644
|
|
|
803fb7 |
--- a/src/journal/journald-native.c
|
|
|
803fb7 |
+++ b/src/journal/journald-native.c
|
|
|
803fb7 |
@@ -457,5 +457,9 @@ int server_open_native_socket(Server*s) {
|
|
|
803fb7 |
if (r < 0)
|
|
|
803fb7 |
return log_error_errno(r, "Failed to add native server fd to event loop: %m");
|
|
|
803fb7 |
|
|
|
803fb7 |
+ r = sd_event_source_set_priority(s->native_event_source, SD_EVENT_PRIORITY_NORMAL+5);
|
|
|
803fb7 |
+ if (r < 0)
|
|
|
803fb7 |
+ return log_error_errno(r, "Failed to adjust native event source priority: %m");
|
|
|
803fb7 |
+
|
|
|
803fb7 |
return 0;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
|
|
|
803fb7 |
index 15a554c34..b8607144b 100644
|
|
|
803fb7 |
--- a/src/journal/journald-stream.c
|
|
|
803fb7 |
+++ b/src/journal/journald-stream.c
|
|
|
803fb7 |
@@ -448,7 +448,7 @@ int server_open_stdout_socket(Server *s) {
|
|
|
803fb7 |
if (r < 0)
|
|
|
803fb7 |
return log_error_errno(r, "Failed to add stdout server fd to event source: %m");
|
|
|
803fb7 |
|
|
|
803fb7 |
- r = sd_event_source_set_priority(s->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+10);
|
|
|
803fb7 |
+ r = sd_event_source_set_priority(s->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+5);
|
|
|
803fb7 |
if (r < 0)
|
|
|
803fb7 |
return log_error_errno(r, "Failed to adjust priority of stdout server event source: %m");
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
|
|
|
803fb7 |
index 4e118aabc..8602b4a95 100644
|
|
|
803fb7 |
--- a/src/journal/journald-syslog.c
|
|
|
803fb7 |
+++ b/src/journal/journald-syslog.c
|
|
|
803fb7 |
@@ -421,6 +421,10 @@ int server_open_syslog_socket(Server *s) {
|
|
|
803fb7 |
if (r < 0)
|
|
|
803fb7 |
return log_error_errno(r, "Failed to add syslog server fd to event loop: %m");
|
|
|
803fb7 |
|
|
|
803fb7 |
+ r = sd_event_source_set_priority(s->syslog_event_source, SD_EVENT_PRIORITY_NORMAL+5);
|
|
|
803fb7 |
+ if (r < 0)
|
|
|
803fb7 |
+ return log_error_errno(r, "Failed to adjust syslog event source priority: %m");
|
|
|
803fb7 |
+
|
|
|
803fb7 |
return 0;
|
|
|
803fb7 |
}
|
|
|
803fb7 |
|