-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFE] enable file logging sink that occasionally checks if original inode/device matches the current per-path one #239
Comments
When at it, Python offers handlers implementing also their own log
So one of the options would be to mimic these as well/instead. On the other hand, |
When speaking of corosync, the risk of losing data in
is amplified by the fact that corosync + logging thread are running with If I understand the thing properly, there are possibly two problems
For 1., it seems solved thanks to But it doesn't look there's a reliable solution for 2. (there's no |
Note that pacemaker itself also uses |
One of the things that were brought up in relation this was a question One of the possibilities to employ in the updated logrotate files is to For the new logrotate config itself and regarding what libqb could be Another alternative would be to use A compromise could be that libqb will create a named pipe
|
To clarify, I was thinking that libqb would simply provide a "reopen log files" function, and the library user could call that from its own signal handler for some available signal (e.g. SIGHUP, SIGUSR1 or SIGUSR2). I don't quite understand the pipe idea. What would write to the pipe, and what would read from it? |
Yes, I don't like the pipe idea. libraries have no business providing that sort of unexpected interface. If logs need rotating then i's the application's responsibility to say when and how it's triggered. |
On 08/12/16 08:14 -0800, Ken Gaillot wrote:
> For the new logrotate config itself and regarding what libqb could be
> taught to do, it was suggested that the libqb user could opt-in to have
> libqb listen for SIGHUP or the like and restart the logging stream
To clarify, I was thinking that libqb would simply provide a "reopen
log files" function, and the library user could call that from its
own signal handler for some available signal (e.g. SIGHUP, SIGUSR1
or SIGUSR2).
Yes, that would be possible, but this is pretty fragile approach:
- libqb's user would need to be changed and recompiled with new
libqb
- libqb's user would need to be extremely cautious about cases
like sigsuspend blocking all the signals but one, etc., opening
whole new class of signal handling issues
- signal is asynchronous, so what if it's delivered just before
libqb's writing procedure proceeds to write to the file that
has just been rotated?
- how is the logrotate script supposed to find out what process
it should kill if there are more?
- how is the logrotate script supposed to tell the signal handler
has already been installed at the libqb's user at early
startup?
- extra complexity at the side of the libqb's user
I don't quite understand the pipe idea. What would write to the
pipe, and what would read from it?
Easy; user's command from logrotate script would echo to it, libqb
would read it to know the stream should be reopened.
For extra sanity, there could be a simple protocol:
1. logrotate script: prerotate: indicates "be careful" to libqb
2. libqb starts checking the inode/idev of the target file
upon each message, reopen the stream if has changed
3. logrotate: performs the rotation
4. libqb switches over
5. logrotate: postrotate: indicates "done" to libqb, which is
for cases that there was some unexpected failure in logrotate
so that libqb doesn't need to be checking inode/idev forever
* * *
On 08/12/16 08:20 -0800, Chrissie Caulfield wrote:
Yes, I don't like the pipe idea. libraries have no business
providing that sort of unexpected interface. If logs need rotating
then i's the application's responsibility to say when and how it's
triggered.
Interpolated, libraries have no business in providing any interface,
when application needs to do anything, it is its own responsibility
:-P
But seriously, libraries are there to encapsulate shared
functionality, and the side issue of logrotating is also shared,
so why not to tackle the problem at one authoritative place when
feasible enough? Why do you think WatchedFileHandler was added
to Python's standard library?
…--
Jan (Poki)
|
On 08/12/16 18:57 +0100, Jan Pokorný wrote:
On 08/12/16 08:14 -0800, Ken Gaillot wrote:
>> For the new logrotate config itself and regarding what libqb could be
>> taught to do, it was suggested that the libqb user could opt-in to have
>> libqb listen for SIGHUP or the like and restart the logging stream
>
> To clarify, I was thinking that libqb would simply provide a "reopen
> log files" function, and the library user could call that from its
> own signal handler for some available signal (e.g. SIGHUP, SIGUSR1
> or SIGUSR2).
Yes, that would be possible, but this is pretty fragile approach:
- libqb's user would need to be changed and recompiled with new
libqb
- libqb's user would need to be extremely cautious about cases
like sigsuspend blocking all the signals but one, etc., opening
whole new class of signal handling issues
- signal is asynchronous, so what if it's delivered just before
libqb's writing procedure proceeds to write to the file that
has just been rotated?
- how is the logrotate script supposed to find out what process
it should kill if there are more?
+ remember that there is no 1:1 mapping between the process and the
logfiles in question, how would it be decided which one to send signal
to if there are more per file (e.g. there are multiple pacemaker
daemons possibly sharing /var/log/pacemaker.log)?
What I propose follow 1:1 mapping principle (file - named pipe).
- how is the logrotate script supposed to tell the signal handler
has already been installed at the libqb's user at early
startup?
- extra complexity at the side of the libqb's user
Note that the proposed change would be a behind-the-curtain one,
actually not imposing any direct change at the library user's
side. If required, it could either write to X.pipe on its own
as a means to control this feature, or there could be additional
API (but the point is it is not strictly required).
…--
Poki
|
My 2cents. Looks like a extremely overengineered solution. Ability to reopen log seems like a viable feature and it's just good enough solution. |
On 12/12/16 00:22 -0800, Jan Friesse wrote:
My 2cents. Looks like a extremely overengineered solution. Ability
to reopen log seems like a viable feature and it's just good enough
solution.
Yes, that would be a subset of what libqb would offer.
In terms of random frobnical package that just want hassle-free
logging facility, i.e., push messages through, don't care about the
details, if would have to be frobnical that would get overengineered
just to control the underlying stream.
Logrotate and the like programs were also "overengineered" to allow
to be conveniently offloaded with some funtionality that could
otherwise other programs/daemons handle on their own. But maintenance
burden many places vs. just a single point was, I believe, the driving
factor here. That's also why I don't propose to perform "logrotating"
directly in libqb.
…--
Jan (Poki)
|
I don't know why, I've missed there was a pre-existing issue #142. |
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 perlogrotate(8)
: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
messagesor when the last message was accepted for emitting more than
Y
seconds ago, would be a better choice, as it combines the advantages:
worst, the data are, in the temporary window, written still to the rotated log
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
.The text was updated successfully, but these errors were encountered: