Blame SOURCES/rsyslog-8.24.0-rhbz1088021-systemd-time-backwards.patch

a856a8
diff -up ./plugins/imjournal/imjournal.c.time ./plugins/imjournal/imjournal.c
a856a8
--- ./plugins/imjournal/imjournal.c.time	2016-12-21 17:50:13.849000000 +0100
a856a8
+++ ./plugins/imjournal/imjournal.c	2016-12-21 18:20:03.908000000 +0100
a856a8
@@ -538,7 +538,24 @@ loadJournalState(void)
a856a8
 						"couldn't seek to cursor `%s'\n", readCursor);
a856a8
 					iRet = RS_RET_ERR;
a856a8
 				} else {
a856a8
+					char * tmp_cursor = NULL;
a856a8
 					sd_journal_next(j);
a856a8
+					/*
a856a8
+ 					* This is resolving the situation when system is after reboot and boot_id doesn't match
a856a8
+ 					* so cursor pointing into "future". Usually sd_journal_next jump to head of journal due to journal aproximation,
a856a8
+ 					* but when system time goes backwards and cursor is still invalid, rsyslog stops logging. We use
a856a8
+ 					* sd_journal_get_cursor to validate our cursor. When cursor is invalid we are trying to jump to the head of journal
a856a8
+ 					* This problem with time is not affecting persistent journal.
a856a8
+ 					* */
a856a8
+					if (sd_journal_get_cursor(j, &tmp_cursor) < 0 && sd_journal_has_persistent_files(j) == 0) {
a856a8
+						errmsg.LogError(0, RS_RET_IO_ERROR, "imjournal: "
a856a8
+                                        	"loaded invalid cursor, seeking to the head of journal\n");
a856a8
+						if (sd_journal_seek_head(j) < 0) {
a856a8
+							errmsg.LogError(0, RS_RET_ERR, "imjournal: "
a856a8
+                                                	"sd_journal_seek_head() failed, when cursor is invalid\n");
a856a8
+							iRet = RS_RET_ERR;
a856a8
+						}
a856a8
+					} 
a856a8
 				}
a856a8
 			} else {
a856a8
 				errmsg.LogError(0, RS_RET_IO_ERROR, "imjournal: "