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

protect against subscriber file corruption #14760

Open
kruskall opened this issue Nov 28, 2024 · 0 comments
Open

protect against subscriber file corruption #14760

kruskall opened this issue Nov 28, 2024 · 0 comments
Labels

Comments

@kruskall
Copy link
Member

APM Server version (apm-server version): 8.16

Description of the problem including expected versus actual behavior:

We're writing the subscriber position using os.WriteFile at

return os.WriteFile(filepath.Join(storageDir, subscriberPositionFile), data, 0644)

The documentation says:

// Since WriteFile requires multiple system calls to complete, a failure mid-operation
// can leave the file in a partially written state.

We should ensure we're not leaving behind a corrupted file if write returns an error. A malformed/corrupted subscriber file could prevent APM Server from starting

Steps to reproduce:

  1. create a corrupted subscriber file
  2. start apm server

Provide logs (if relevant):

We've observed this a few times with the error

error parsing subscriber position file: unexpected end of JSON input
@kruskall kruskall added the bug label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant