Skip to content
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

auditlog: logging.FileHander() is not fork-safe #124

Open
tiran opened this issue Mar 2, 2017 · 2 comments
Open

auditlog: logging.FileHander() is not fork-safe #124

tiran opened this issue Mar 2, 2017 · 2 comments
Labels
Milestone

Comments

@tiran
Copy link
Member

tiran commented Mar 2, 2017

Custodia uses logging.FileHandler to log audit events to a log file. The file handler is thread-safe but it is not multi-process safe. It does not synchronize writes for multiple writers or inherited FDs in forked child processes.

I don't have a quick solution at hand.

@tiran tiran added the bug label Mar 2, 2017
@tiran tiran changed the title auditlog: logging.FileHander() is not fork auditlog: logging.FileHander() is not fork-safe Mar 2, 2017
@simo5
Copy link
Member

simo5 commented Mar 2, 2017

One thing we could do is to have the logging go to the parent process over a FD instead, and have the parent process collect it and commit it to the log file all at once when the child dies, or on a message based boundary (TBD). (This will make log rotation easier if we want to do it from within custodia)

@tiran
Copy link
Member Author

tiran commented Mar 2, 2017

Either in the main process of we fork off a logging process.

Python has a watching file handler that handles flush, close and reopen: https://github.com/python/cpython/blob/3.6/Lib/logging/handlers.py#L446

@tiran tiran added this to the future milestone Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants