Bug 15090 - CTDB child process logging does not work as expected
Summary: CTDB child process logging does not work as expected
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: CTDB (show other bugs)
Version: 4.16.1
Hardware: All All
: P5 regression (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
Depends on:
Reported: 2022-06-08 11:58 UTC by Martin Schwenke
Modified: 2022-06-18 09:59 UTC (History)
2 users (show)

See Also:

Patch for v4-16-test (6.75 KB, patch)
2022-06-16 22:57 UTC, Martin Schwenke
vl: review+

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schwenke 2022-06-08 11:58:16 UTC
Since commit 10d15c9e5dfe4e8595d0b322c96f474fc7078f46, CTDB uses Samba's file logging.  When the log file is (re)opened, stderr is dup()ed to the log file.  This overrides CTDB's capture of stderr, so that stderr in subprocesses will automatically be captured and logged.  This means subprocesses that usefprintf(stderr, ...) now have the output written into the log file without a debug header.  Moreover, the CTDB code that logs any captured output calls dbgtext() rather than DEBUG() so, even if the initial problem can be worked around, these captured entries are logged without a header.  This means it is not possible to sort logs to get a cluster-wide view.

Before the switch to Samba's file logging, CTDB uses a callback that always added a debug header.

A workaround is needed in Samba's file logging (in debug.c) and the relevant CTDB logging code needs to be changes to use DEBUG().
Comment 1 Samba QA Contact 2022-06-16 13:34:04 UTC
This bug was referenced in samba master:

Comment 2 Martin Schwenke 2022-06-16 22:57:19 UTC
Created attachment 17367 [details]
Patch for v4-16-test

Cherry picks cleanly into v4-16-test.

Smoke tested with:

  $ VALGRIND="valgrind -q" ./tests/run_tests.sh tests/INTEGRATION/simple/cluster.016.reclock_move_lock_dir.sh
  [test passes]
  $ ./tests/local_daemons.sh  tests/var/INTEGRATION/simple/ print-log all | less
  [messages from ctdb_mutex_fcntl_helper are correctly logged]
Comment 3 Jule Anger 2022-06-18 08:37:43 UTC
Pushed to autobuild-v4-16-test.
Comment 4 Samba QA Contact 2022-06-18 09:56:27 UTC
This bug was referenced in samba v4-16-test:

Comment 5 Jule Anger 2022-06-18 09:59:24 UTC
Closing out bug report.