Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/util/log: unify explicit flush of network and file sinks #102772

Merged
merged 1 commit into from
May 15, 2023

Commits on May 15, 2023

  1. pkg/util/log: unify explicit flush of network and file sinks

    Ref: cockroachdb#101562
    
    both for files *and* network sinks, such as fluent-servers.
    
    I received some feedback that we shouldn't divide these
    flush operations based on sink type, and instead we should
    unify the flush operation to flush both (as the crash reporter
    already does).
    
    The existing function to flush just the file sinks is
    quite widely used. Introducing flushing of network sinks
    begs the question, "What if this adds to the runtime of
    code using this explicit flush mechanism?"
    
    Well, the existing FlushFileSinks calls fsync() [1] with
    F_FULLFSYNC [2]. IIUC, this means that it already is a
    blocking operation as the fsync() call will wait for the
    buffered data to be written to permanent storage (not just
    the disk cache). Given that, I think any caller of this
    function already assumes it's a blocking operation and
    therefore should be tolerant of that.
    
    [1]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html
    [2]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html#//apple_ref/doc/man/2/fcntl
    
    Nonetheless, we implement a timeout mechanism for the
    flushing of the buffered network sinks as an added
    protection.
    abarganier committed May 15, 2023
    Configuration menu
    Copy the full SHA
    1629e11 View commit details
    Browse the repository at this point in the history