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

journalctl --sync should guarantee all currently in flight logs are written to the journal #32539

Closed
DaanDeMeyer opened this issue Apr 28, 2024 · 5 comments · Fixed by #32617
Closed
Labels
journal RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@DaanDeMeyer
Copy link
Contributor

DaanDeMeyer commented Apr 28, 2024

Component

No response

Is your feature request related to a problem? Please describe

We currently have a bunch of racy code in our integration tests to check if a message was written to the journal. This is because there's is no command in journalctl to wait until all currently in flight logs have been written to the journal. We could implement this by iterating over all open log streams, checking the number of bytes in each stream and only reading up to that amount from the socket. This will guarantee all currently in flight logs have been written to the journal.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

The systemd version you checked that didn't have the feature you are asking for

No response

@DaanDeMeyer DaanDeMeyer added RFE 🎁 Request for Enhancement, i.e. a feature request journal labels Apr 28, 2024
@poettering
Copy link
Member

hmm what's wrong with the existing journalctl --sync? what am i missing?

@DaanDeMeyer
Copy link
Contributor Author

@poettering AFAIK that doesn't seem to do anything with logs that haven't been read from the service's file descriptor(s) yet? If I call journalctl --sync before journald reads the logs from the unit's file descriptor (or /run/systemd/journal/socket), then journalctl --sync doesn't actually guarantee those logs will be written to the journal?

If I currently do something like this

systemctl start oneshot-unit-that-logs-to-journal
journalctl --sync
journalctl --grep "log-message-from-oneshot-unit-that-logs-to-journal"

The journalctl grep might return an entry, or it might not return any entries at all. What I want is a way to ensure that that call to journalctl --grep will contain the logs from the oneshot service.

@poettering
Copy link
Member

hmm, the idea was that the --sync stuff does exactly what you are looking for here, i.e. it only returns once every stream was fully processed.

@yuwata
Copy link
Member

yuwata commented Apr 30, 2024

Yeah, currently journalctl --sync does not check stream, and there may be some pending data.

@yuwata
Copy link
Member

yuwata commented May 1, 2024

-> #32617.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
journal RFE 🎁 Request for Enhancement, i.e. a feature request
Development

Successfully merging a pull request may close this issue.

3 participants