Skip to content

Commit

Permalink
Fix empty registry file on machine crash (elastic#3668)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin authored and andrewkroh committed Feb 27, 2017
1 parent 98dde8b commit e2e58c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Always use absolute path for event and registry. {pull}3328[3328]
- Raise an exception in case there is a syntax error in one of the configuration files available under
filebeat.config_dir. {pull}3573[3573]
- Fix empty registry file on machine crash. {issue}3537[3537]

*Heartbeat*

Expand Down
2 changes: 1 addition & 1 deletion filebeat/registrar/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (r *Registrar) writeRegistry() error {
logp.Debug("registrar", "Write registry file: %s", r.registryFile)

tempfile := r.registryFile + ".new"
f, err := os.OpenFile(tempfile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
f, err := os.OpenFile(tempfile, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0600)
if err != nil {
logp.Err("Failed to create tempfile (%s) for writing: %s", tempfile, err)
return err
Expand Down
2 changes: 1 addition & 1 deletion winlogbeat/checkpoint/file_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package checkpoint
import "os"

func create(path string) (*os.File, error) {
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0600)
}

0 comments on commit e2e58c0

Please sign in to comment.