teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0001-journal-letting-interleaved-seqnums-go.patch

Harald Hoyer f9af88
From 53113dc8254cae9a27e321e539d2d876677e61b9 Mon Sep 17 00:00:00 2001
Harald Hoyer f9af88
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Harald Hoyer f9af88
Date: Fri, 7 Jun 2013 22:01:03 -0400
Harald Hoyer f9af88
Subject: [PATCH] journal: letting (interleaved) seqnums go
Harald Hoyer f9af88
Harald Hoyer f9af88
In the following scenario:
Harald Hoyer f9af88
  server creates system.journal
Harald Hoyer f9af88
  server creates user-1000.journal
Harald Hoyer f9af88
both journals share the same seqnum_id.
Harald Hoyer f9af88
Then
Harald Hoyer f9af88
  server writes to user-1000.journal first,
Harald Hoyer f9af88
  and server writes to system.journal a bit later,
Harald Hoyer f9af88
and everything is fine.
Harald Hoyer f9af88
The server then terminates (crash, reboot, rsyslog testing,
Harald Hoyer f9af88
whatever), and user-1000.journal has entries which end with
Harald Hoyer f9af88
a lower seqnum than system.journal. Now
Harald Hoyer f9af88
  server is restarted
Harald Hoyer f9af88
  server opens user-1000.journal and writes entries to it...
Harald Hoyer f9af88
BAM! duplicate seqnums for the same seqnum_id.
Harald Hoyer f9af88
Harald Hoyer f9af88
Now, we usually don't see that happen, because system.journal
Harald Hoyer f9af88
is closed last, and opened first. Since usually at least one
Harald Hoyer f9af88
message is written during boot and lands in the system.journal,
Harald Hoyer f9af88
the seqnum is initialized from it, and is set to a number higher
Harald Hoyer f9af88
than than anything found in user journals. Nevertheless, if
Harald Hoyer f9af88
system.journal is corrupted and is rotated, it can happen that
Harald Hoyer f9af88
an entry is written to the user journal with a seqnum that is
Harald Hoyer f9af88
a duplicate with an entry found in the corrupted system.journal~.
Harald Hoyer f9af88
When browsing the journal, journalctl can fall into a loop
Harald Hoyer f9af88
where it tries to follow the seqnums, and tries to go the
Harald Hoyer f9af88
next location by seqnum, and is transported back in time to
Harald Hoyer f9af88
to the older duplicate seqnum. There is not way to find
Harald Hoyer f9af88
out the maximum seqnum used in a multiple files, without
Harald Hoyer f9af88
actually looking at all of them. But we don't want to do
Harald Hoyer f9af88
that because it would be slow, and actually it isn't really
Harald Hoyer f9af88
possible, because a file might e.g. be temporarily unaccessible.
Harald Hoyer f9af88
Harald Hoyer f9af88
Fix the problem by using different seqnum series for user
Harald Hoyer f9af88
journals. Using the same seqnum series for rotated journals
Harald Hoyer f9af88
is still fine, because we know that nothing will write
Harald Hoyer f9af88
to the rotated journal anymore.
Harald Hoyer f9af88
Harald Hoyer f9af88
Likely related:
Harald Hoyer f9af88
https://bugs.freedesktop.org/show_bug.cgi?id=64566
Harald Hoyer f9af88
https://bugs.freedesktop.org/show_bug.cgi?id=59856
Harald Hoyer f9af88
https://bugs.freedesktop.org/show_bug.cgi?id=64296
Harald Hoyer f9af88
https://bugs.archlinux.org/task/35581
Harald Hoyer f9af88
https://bugzilla.novell.com/show_bug.cgi?id=817778
Harald Hoyer f9af88
Harald Hoyer f9af88
Possibly related:
Harald Hoyer f9af88
https://bugs.freedesktop.org/show_bug.cgi?id=64293
Harald Hoyer f9af88
Harald Hoyer f9af88
Conflicts:
Harald Hoyer f9af88
	src/journal/journald-server.c
Harald Hoyer f9af88
---
Harald Hoyer f9af88
 src/journal/journald-server.c | 2 +-
Harald Hoyer f9af88
 1 file changed, 1 insertion(+), 1 deletion(-)
Harald Hoyer f9af88
Harald Hoyer f9af88
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
Harald Hoyer f9af88
index cc52b8a..cde63c8 100644
Harald Hoyer f9af88
--- a/src/journal/journald-server.c
Harald Hoyer f9af88
+++ b/src/journal/journald-server.c
Harald Hoyer f9af88
@@ -280,7 +280,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
Harald Hoyer f9af88
                 journal_file_close(f);
Harald Hoyer f9af88
         }
Harald Hoyer f9af88
 
Harald Hoyer f9af88
-        r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, s->system_journal, &f);
Harald Hoyer f9af88
+        r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &f);
Harald Hoyer f9af88
         free(p);
Harald Hoyer f9af88
 
Harald Hoyer f9af88
         if (r < 0)
Harald Hoyer f9af88
-- 
Harald Hoyer f9af88
1.8.2.1
Harald Hoyer f9af88