[pve-devel] [PATCH cluster 3/3] pmxcfs: enable QB log thread

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Oct 1 10:53:26 CEST 2020


since pmxcfs is a multi-threaded application, and `man qblog.h`
explicitly states:

 Thread safe non-blocking logging.

 Logging is only thread safe when threaded logging is in use. If you
 plan on logging from multiple threads, you must initialize libqb's
 logger thread and use qb_log_filter_ctl to set the QB_LOG_CONF_THREADED
 flag on all the logging targets in use.

without this we can lose log messages under high load, especially when
enabling debug mode to trouble-shoot issues.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---

Notes:
    this would have saved Alexandre and me quite a bit of back and forth and false
    leads ;)

 data/src/pmxcfs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/data/src/pmxcfs.c b/data/src/pmxcfs.c
index 00aa53d..3146121 100644
--- a/data/src/pmxcfs.c
+++ b/data/src/pmxcfs.c
@@ -1005,8 +1005,13 @@ int main(int argc, char *argv[])
 		}
 	} else {
 		write_pidfile(getpid());
+		// foreground == STDERR logging enabled, make it threaded
+		qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_THREADED, QB_TRUE);
 	}
 
+	qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_THREADED, QB_TRUE);
+	qb_log_thread_start();
+
 	wrote_pidfile = TRUE;
 
 	cfs_loop_t *corosync_loop = cfs_loop_new(fuse);
-- 
2.20.1






More information about the pve-devel mailing list