Skip to content

Commit

Permalink
refactor: drop custom fsync implementation (#42066)
Browse files Browse the repository at this point in the history
* refactor: drop custom fsync implement

upstream is using F_FULLFSYNC on darwin
call stdlib f.sync and remove custom fsync implementation

* lint: fix linting errors

* Update util.go
  • Loading branch information
kruskall authored Mar 5, 2025
1 parent 0536310 commit 40a68d4
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 148 deletions.
6 changes: 3 additions & 3 deletions libbeat/statestore/backend/memlog/diskstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (s *diskstore) Close() error {
// always sync log file on ordinary shutdown.
err := s.logBuf.Flush()
if err == nil {
err = syncFile(s.logFile)
err = s.logFile.Sync()
}
s.logFile.Close()
s.logFile = nil
Expand Down Expand Up @@ -380,7 +380,7 @@ func (s *diskstore) checkpointTmpFile(tempfile string, states map[string]entry)
return "", err
}

if err = syncFile(f); err != nil {
if err = f.Sync(); err != nil {
return "", err
}

Expand Down Expand Up @@ -658,7 +658,7 @@ func writeMetaFile(home string, mode os.FileMode) error {
return err
}

if err := syncFile(f); err != nil {
if err := f.Sync(); err != nil {
return err
}

Expand Down
10 changes: 1 addition & 9 deletions libbeat/statestore/backend/memlog/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
package memlog

import (
"errors"
"io"
"os"
"runtime"
"syscall"
)

// countWriter keeps track of the amount of bytes written over time.
Expand All @@ -37,12 +35,6 @@ func (c *countWriter) Write(p []byte) (int, error) {
return n, err
}

var _ = isRetryErr

func isRetryErr(err error) bool {
return errors.Is(err, syscall.EINTR) || errors.Is(err, syscall.EAGAIN)
}

// trySyncPath provides a best-effort fsync on path (directory). The fsync is required by some
// filesystems, so to update the parents directory metadata to actually
// contain the new file being rotated in.
Expand All @@ -53,7 +45,7 @@ func trySyncPath(path string) {
}
defer f.Close()
//nolint:errcheck // ignore error
syncFile(f)
f.Sync()
}

// pathEnsurePermissions checks if the file permissions for the given file match wantPerm.
Expand Down
74 changes: 0 additions & 74 deletions libbeat/statestore/backend/memlog/util_darwin.go

This file was deleted.

36 changes: 0 additions & 36 deletions libbeat/statestore/backend/memlog/util_other.go

This file was deleted.

26 changes: 0 additions & 26 deletions libbeat/statestore/backend/memlog/util_windows.go

This file was deleted.

0 comments on commit 40a68d4

Please sign in to comment.