Skip to content

Fix newlines not appearing between new log entries

Stan Hu requested to merge sh-fix-nonatomic-puts into master

In https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5017, we observed that lots of log messages were being dropped by Fluentd due to missing newlines.

This occurs because there is a bug in Ruby where IO#puts calls write() twice: once to write the main text, and another to write the newline (https://bugs.ruby-lang.org/issues/14042). In a highly concurrent environment like GitLab.com, this can lead to interleaved newlines.

A workaround is to use IO#print and append the newline ourselves.

Closes https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5017

Edited by Stan Hu

Merge request reports