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

Add option to have ClamAV clamd use less memory on startup #64

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

ksylvan
Copy link

@ksylvan ksylvan commented Mar 9, 2024

Description

Adds a new variable CLAMD_MEMORY_FIX to use the new ClamAV ConcurrentDatabaseReload option.

This reduces memory in the mailserver container on startup, with the downside that clamd will
block any new scans until reload is complete.

Fixes #63

  • The current behavior: out-of-memory crashes on my mailserver host.
  • Desired behavior: Server is stable, no memory issues.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Status

  • Ready
  • In development
  • Hold

How has this been tested ?

Tested this on my production server.

So far, it seems to be working. The load spiked, but not as much as before, then settled back down.

Will keep testing and update the PR.

$ w
 23:46:19 up 10 min,  1 user,  load average: 0.08, 0.10, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
deploy   pts/0    76.132.225.162   23:35    1.00s  0.08s  0.00s w

$ docker-compose exec mailserver /bin/bash
root@mail:/# tail /etc/clamav/clamd.conf 
LogFile /var/log/clamav/clamav.log
LogTime true
LogFileUnlock false
LogFileMaxSize 0
Bytecode true
BytecodeSecurity TrustSigned
BytecodeTimeout 60000
OnAccessMaxFileSize 5M
TCPSocket 3310
ConcurrentDatabaseReload no

@ksylvan ksylvan requested review from AndrewSav and SaraSmiseth March 9, 2024 07:50
@ksylvan
Copy link
Author

ksylvan commented Mar 9, 2024

image

After the latest reboot (upon upgrading my base OS to Debian 12 "bookworm"), here is what rspamd status looks like. I am thrilled because this dashboard wasn't even loading recently, and now it comes up fast.

@ksylvan ksylvan merged commit fd944a7 into mailserver2:master Mar 11, 2024
8 checks passed
@ksylvan
Copy link
Author

ksylvan commented Mar 11, 2024

I merged this. Without the CLAMD_MEMORY_FIX environment variable, this is a no-op for existing installs, and I've tested this over the last few days on two different production domains I have running the mailserver stack.

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

Successfully merging this pull request may close these issues.

clamd process memory balloons on first loading, causes out-of-memory hangs
1 participant