ClusterLabs / ClusterLabs/libqb

[RFE] enable file logging sink that occasionally checks if original inode/device matches the current per-path one

Open
#239 11 comments 0 reactions 0 assignees View on GitHub
design RFE
Dominant language
C
Stars
171
Forks
103
PR merge metrics
No merged PRs in 30d

Description

Working on something entirely unrelated, I came across something that
has a potential to affect pacemaker+corosync stack (apparently using
libqb which can possibly offer the solution) wrt. logging when logrotate
program installed and scheduled to run regularly (common case with
the former precondition).

The problem is that logrotate.d configuration shipped with corosync:

https://github.com/corosync/corosync/blob/v2.4.2/conf/logrotate/corosync.in#L4

contains `copytruncate` keyword, which asks for troubles per `logrotate(8)`:

> Note that there is a very small time slice between copying the file
> and truncating it, so some logging data might be lost.

That's definitely undesired effect at any rate.

As that unrelated stuff that lead me here was Python based and related
to logging, the solution was quite simple:

https://hg.python.org/cpython/file/3.6/Lib/logging/handlers.py#l416

i.e., using `logging.handlers.WatchedFileHandler` from standard library.

From there, immediate extrapolation onto libqb feature set can be seen,
and hence this RFE.

The Python's implementation is pretty simple, though it's not very
efficient. I can imagine that making the check every `X` messages
or when the last message was accepted for emitting more than `Y`
seconds ago, would be a better choice, as it combines the advantages:

- nothing being lost (unless even more extreme circumstances), because at
worst, the data are, in the temporary window, written still to the rotated log
- efficiency, because it doesn't `stat` the target file every time,
especially if there's a burst of messages to proceed

When this is done, it would be wise to have corosync drop `copytruncate`
directive from logrotate configuration, only relying on implicit rotating
and maybe implicit/explicit `create`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.