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

naemon reload does not release deleted objects.cache file #462

Closed
pvdputte opened this issue Apr 28, 2024 · 3 comments
Closed

naemon reload does not release deleted objects.cache file #462

pvdputte opened this issue Apr 28, 2024 · 3 comments

Comments

@pvdputte
Copy link
Contributor

It appears that naemon keeps previous instances of the objects.cache file open when it reloads its config. As a result these cannot be freed in the filesystem and in no time the disk fills up. (our objects.cache is around 450 MiB)

When I restart naemon, everything is freed again.

Until recently we were running naemon 1.0.8, with that version this problem did not occur.

I've been running 1.4 for a few months now but until now I restarted naemon on each config change instead of reloading it (cfr. naemon/naemon-livestatus#117 (comment)). That's why I'm only noticing this now.

# ls -l /proc/2585040/fd|grep objects.cache
lrwx------ 1 naemon naemon 64 Apr 28 18:27 18 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 21 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 22 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 23 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 24 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 25 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 26 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 27 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 28 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 29 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 30 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 31 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 32 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 33 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 34 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 35 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 36 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 37 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 38 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 39 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 40 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 41 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 42 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 43 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 18:27 44 -> /var/lib/naemon/objects.cache

To reproduce:

# systemctl restart naemon
# ls -l /proc/2858224/fd|grep objects.cache
lrwx------ 1 naemon naemon 64 Apr 28 21:41 18 -> /var/lib/naemon/objects.cache

# systemctl reload naemon
# ls -l /proc/2858224/fd|grep objects.cache
lrwx------ 1 naemon naemon 64 Apr 28 21:41 18 -> /var/lib/naemon/objects.cache (deleted)
lrwx------ 1 naemon naemon 64 Apr 28 21:41 21 -> /var/lib/naemon/objects.cache

@sni
Copy link
Contributor

sni commented Apr 29, 2024

Indeed, i can reproduce that. Haven't noticed that so far, because we disable the object cache by setting: object_cache_file=/dev/null
Which would be a workaround for you too. The object.cache is usually not required and just a
leftover from the time when guis need to parse that file to acutally display things instead of just using livestatus.

@pvdputte
Copy link
Contributor Author

Perfect, thanks 👌

sni added a commit to sni/naemon-core that referenced this issue Nov 10, 2024
using fopen opens the object.cache a second time and naemon closes just one afterwards.
So with every write of the objects.cache file, one reference will be kept and prevents
the file from beeing deleted which finally fills the disk with deleted files.
Using fdopen solves the issue, since it just reuses the existing fd.
@sni
Copy link
Contributor

sni commented Nov 10, 2024

Took a bit, but should be fixed with #483

@sni sni closed this as completed in b9a6af3 Nov 13, 2024
@sni sni mentioned this issue Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants