Skip to content

journald: when we fail to add a new entry to a journal, return the seqno - #18670

Merged
poettering merged 1 commit into
systemd:mainfrom
poettering:journal-reuse-seqnum
Feb 18, 2021
Merged

poettering merged 1 commit into
systemd:mainfrom
poettering:journal-reuse-seqnum

Conversation

@poettering

Copy link
Copy Markdown
Member

Fixes: #18005

@poettering

Copy link
Copy Markdown
Member Author

@syyhao1994 any chance you can test if this fixes the issue for you?

@bluca bluca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - let's maybe wait a little to see if there's any feedback from the reporter

@syyhao1994

Copy link
Copy Markdown
Contributor

I tried the modification and it could solve the issue as you said! 👍
Although the content of last entry in [email protected] and the beginning entry in the [email protected] are the same, but the beginning entry in the [email protected] would be skipped when i used journalctl to get all the journald logs.

But what confused me is that why we failed to insert journal entry to the last of [email protected] but we could still get the log by using journactl --file [email protected]?

@poettering

Copy link
Copy Markdown
Member Author

@syyhao1994 most likely adding the entry worked, but then linking it up didn't. but that's OK.

so, in journald first a log entry is written to the end of the journal file, and afterwards it is inserted into a bunch of lookup tables. These lookup tables are in the front usually, and thus don't need allocation – except if they are full, in which case we'll allocate a new table at the end of the file, of double the size as the old one. These tables are then chained up. at the beginning of the files the tables are short, at the end they get much larger. this means there's a good chance allocating the table will fail, and we can't link them up hence. — but that is actually entirely OK.

These mentioned tables exist purely for finding stuff in the file, i.e. for each field vlaue there's one chain of these tables. So if you know where the field is you also know all entries by looking at these tables. Now, if the tables cannot be created this simply means the entries cannot be found. But that is fine, given they'll be found in the new file. i.e. it doesn't matter where they are found, all that matters is that they are found.

If you iterate linearly through a journal file without having any filters applied you'll always see all entries btw, hence in that case you'll se the entries twice (except that now you won#t anymore, once i merge this PR)

Hope that makes some sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

journald:There is always a repeated log between the .journal files

4 participants