[Bug 175] New: syslog-ng doesnt perform fsync() with fsync option enabled on file destinations
https://bugzilla.balabit.com/show_bug.cgi?id=175 Summary: syslog-ng doesnt perform fsync() with fsync option enabled on file destinations Product: syslog-ng Version: 3.3.x Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: unspecified Component: syslog-ng AssignedTo: bazsi@balabit.hu ReportedBy: bugzilla.syslogng@feystorm.net Type of the Report: --- Estimated Hours: 0.0 While trying to track down an issue on our production system where our box would experience hanging issues every 30 seconds, I discovered this was because syslog-ng wasnt flushing its data, and so when the linux pdflush woke up, it would flush out a ton of data to NFS causing syslog and other applications to hang until the flush completed. Ultimately this was causing messages to be dropped as input buffers were filling up while syslog-ng was hung. This shouldnt have been happening as I have syslog-ng configured with the flush option enabled on the file destination which writes to NFS. I have a workaround in place by forcing pdflush to run more frequently, and have also increased several of the input buffers so they dont fill up so fast. I confirmed this issue by building syslog-ng-3.3.5 and putting a gdb break point on lib/logtransport.c:170, and the break point never triggers. I do have a question about the fsync option as well. Does this option tell syslog-ng to flush() after every write, or after all lines have been written (like from the flush_lines or flush_timeout() options)? If it flushes after every write, would it be possible to get an option to flush only once all the messages in the batch have been written? This is the stripped down configuration I have duplicated the issue with: @version: 3.3 options { keep_hostname(yes); chain_hostnames(no); normalize_hostnames(yes); use_dns(no); use_fqdn(yes); stats_freq(0); mark_freq(0); create_dirs(yes); dir_perm(0755); perm(0644); }; source s_sys { unix-dgram("/dev/log" max-connections(256)); internal(); file("/proc/kmsg"); }; destination d_default { file("/var/log/$FACILITY" flush_lines(1) fsync(yes)); }; log { source(s_sys); destination(d_default); flags(fallback); }; -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 --- Comment #1 from Balazs Scheidler <bazsi@balabit.hu> 2012-05-01 14:25:21 --- indeed, this behaviour was lost when implementing LogProtoFileWriter which bypasses LogTransport objects completely, so the fsync(yes) stuff doesn't work. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 --- Comment #2 from Balazs Scheidler <bazsi@balabit.hu> 2012-05-11 17:45:29 --- Created an attachment (id=61) --> (https://bugzilla.balabit.com/attachment.cgi?id=61) patch to move fsync to LogProtoFileWriter This untested patch should fix this. Gergely, can you please integrate this if it indeed fixes the problem for Patrick? thanks. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |algernon@balabit.hu --- Comment #3 from Gergely Nagy <algernon@balabit.hu> 2012-05-11 21:55:36 --- (In reply to comment #2)
Created an attachment (id=61) --> (https://bugzilla.balabit.com/attachment.cgi?id=61) [details] patch to move fsync to LogProtoFileWriter
This untested patch should fix this. Gergely, can you please integrate this if it indeed fixes the problem for Patrick? thanks.
The patch looks good to me, and will try to test it. Patrick, if you could test it too, that would be most amazing! (I can prepare a patched tarball, if that'd make it easier) -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 --- Comment #4 from Gergely Nagy <algernon@balabit.hu> 2012-05-12 14:26:37 --- (In reply to comment #0)
I do have a question about the fsync option as well. Does this option tell syslog-ng to flush() after every write, or after all lines have been written (like from the flush_lines or flush_timeout() options)? If it flushes after every write, would it be possible to get an option to flush only once all the messages in the batch have been written?
With the patch Bazsi posted, fsync(yes) will trigger an fsync after every write, assuming a file() destination (tested & verified, I'll apply it to 3.3 git in a couple of minutes). However, as far as I see, writes are done in batches, whenever flush_lines() or flush_timeout() triggers a batch, so fsync(yes) will mean that syslog-ng will fsync after each flush-lines() number of lines, as that is how often it does the write. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 --- Comment #5 from Balazs Scheidler <bazsi@balabit.hu> 2012-05-14 09:44:37 --- this was my intention, if someone wants to fsync after every write, she can set flush-lines to 1. thanks for checking it out. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |3.3.6 AssignedTo|bazsi@balabit.hu |algernon@balabit.hu -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=175 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution| |FIXED Status|NEW |RESOLVED --- Comment #6 from Gergely Nagy <algernon@balabit.hu> 2012-05-31 17:50:20 --- This is fixed in git, and will be part of 3.3.6 - marking it resolved fixed accordingly. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
participants (1)
-
bugzilla@bugzilla.balabit.com