Repository navigation
Description
systemd version the issue has been seen with
243
Used distribution
Fedora 31
Expected behaviour you didn't see
I have a program which should print a hex dump to stderr - resulting in the output shown in the journal. I have created a demo program here: https://gist.github.com/georgmu/7178426db59813e108e0d29b77b84c31 .
I run the program withsystemd-run --user ./hextest 0The expeceted behavoir is to always show all lines of the hex dump.
When running with argument 1, 2 or 3 (1 or 3 increases the byte in the hexdump , 2 or 3 print the offset in the first column), the lines are not the same and all lines are printed in the journal.
When run without systemd-run, I get the complete output to stderr:
starting...
hex dump of 512 bytes:
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
Exiting...
Unexpected behaviour you saw
journalctl --user only shows some lines if the lines are the same (hextest run in mode 0). The number of lines shown is not stable. Sometimes there are 2-4 lines, sometimes 10 lines:
Feb 18 11:58:18 nb-georg hextest[527768]: starting...
Feb 18 11:58:18 nb-georg hextest[527768]: hex dump of 512 bytes:
Feb 18 11:58:18 nb-georg hextest[527768]: 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
Feb 18 11:58:18 nb-georg hextest[527768]: 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 | ................
Feb 18 11:58:18 nb-georg hextest[527768]: Exiting...
The output of the hex dump should always be 32 lines long.
Activity
georgmu commentedon Feb 19, 2020
When checking output with
journalctl --user -o verbose, I can see that the sequence numbers increase, so the initial log record seems to be generated.0x7a298 - 0x7a276 + 1 = 35, which is the expected number of log records (32 dump lines + 3 extra lines)
georgmu commentedon Feb 19, 2020
The problem seems to be that all records are equal AND the timestamps are also equal. I modified the test-journal-stream.c to only add the same number (NUMBER=1 instead of NUMBER=i) and to keep the journals (commented the rm_rf call at the end). When the times increase, everything is fine. If the times stay the same (move the
dual_timestamp_get()out of the loop), only the first equal entry is added (as seen by the serial numbers in the verbose output).Now when the
read()reads multiple lines at once, which are splitted afterwards, all these lines seem to be added with the same time and the entry is not added at all.georgmu commentedon Feb 19, 2020
The problem is not in writing, but in reading the journal. The journal contains the record (checked comparing hexdumps of the journal).
The problem is in function
next_beyond_location(). The functioncompare_with_location()returns0for the duplicate record. The comment above this section states:Well. Here we have two (validly equal) entries in the same journal file.
Hard-coding
foundtotruehere solves it (duplicate entries are printed), but this is not the real solution here.Maybe it is possible to check if the entries are from the same or different journals?
[-]journald silently suppresses duplicate log messages[/-][+]journalctl silently suppresses valid duplicate log messages[/+]journalctl: show duplicate entries if they are from the same file (#1…
mrc0mmand commentedon Mar 18, 2020
Resolved by #14913.
journalctl: show duplicate entries if they are from the same file (sy…