Repository navigation
Conversation
_parent only waited for unbound's run script to start, not for unbound to accept connections. On a first start freshclam could run before that, fail to resolve its mirrors and exit, and clamd was then started without a database. It crashed about once a second until a database arrived, and the watchdog stopped it for good at the 20th failure. This failed the default suite on master: clamd had restarted 4 times, and its errors were in mail.err. Wait until 127.0.0.1:53 accepts connections, for about 30 seconds at most, then log a warning and carry on. Nothing changes with DISABLE_DNS_RESOLVER=true.
nc reports each successful connection on stderr, which ends up in the container log twice per start.
"cron job stderr goes to mail.err" makes current-dbs.txt root-owned so that the job, running as clamav, cannot write it. When the update at startup fails, the file is first created by a job the tests run through su, whose umask is 0002, so it is group-writable and clamav can still write it after the chown. Set its mode as well. The diagnostics added in mailserver2#111 led to this and are removed. "mail.err does not exist" failed when rspamd's public fuzzy server was slow to answer, which rspamd logs as an error. Ignore that message only; any other line still fails the test.
AndrewSav
force-pushed
the
fix-dns-startup-race
branch
from
December 5, 2026 10:18
f4bd1c8 to
c206970
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Note
TLDR: More races fixes.
What is the current behavior (you can also link to an open issue here) ?
1. Startup race. Run 47417854223 (master,
cf6c344) failed two default tests: clamd had restarted 4 times, and its errors were inmail.err. The container log shows why:Could not resolve hostname_parent/runwaits for unbound withs6-svwait -u, which only waits for its run script to start, not for unbound to accept connections.This is not only a test problem. s6 stops clamd for good after 20 failures. With unbound delayed by 3 seconds, clamd was still down after DNS had come up.
2.
cron job stderr goes to mail.err. This is the failure Report why the mail.err cron test fails when it does #111 added diagnostics for, and they caught it in this run on my fork. The test makescurrent-dbs.txtroot-owned so that the job, running asclamav, cannot write it. The report shows the job did write it, and handed nothing tologger:su, which givesclamava umask of 0002 (0022 at startup), so the file is writable by theclamavgroup.chown rootdoes not change the group, soclamavcan still write the file.I reproduced this by making only the startup update's downloads fail. Why that update failed in CI is not in the log, so I don't know.
3.
mail.err does not exist. In the same run on my fork, rspamd logged an error becausefuzzy-a.rspamd.com, a public server, did not answer in time. Any line inmail.errfails the test.No mail was being scanned at the time. The error was logged while
checking rspamd: 7 messages with action no actionranrspamc stat. That test took 4.3 seconds, about 0.3 seconds in the other runs. I checked locally thatrspamc statmakes rspamd's controller query the fuzzy server, for its hash counts. The rule waits 2 seconds and retries once, which matches the 4.3 seconds. The statistics still came back, and that test and the otherrspamc stattests passed.What is the new behavior (if this is a feature change) ?
_parent/runwaits until127.0.0.1:53accepts connections before it starts postfix and everything after it. The wait is skipped withDISABLE_DNS_RESOLVER=true. After about 30 seconds it logs a warning and carries on, as before this change.mail.errtest ignores that one rspamd message, and a comment in the test says why. The test is still useful: any other line fails it.Not covered. If unbound never comes up, or the first download fails for another reason, clamd is still started without a database. Stopping the container instead would be a change for the whole image, since no failed service stops it today. Stop the container when a service it needs cannot run AndrewSav/mailserver#2 covers that.
Type of change
Status
Todo List
How has this been tested ?
Default suite on this branch, fresh build: 140/140. I did not run the other suites locally.
The startup race, forced by adding
sleep 3to unbound's run script, before it starts unbound. Same image, only_parent/rundiffers:_parent/runmail.err, clamd loads its databaseWith unbound never starting, the warning is logged after 30 seconds and the other services start.
The two test fixes, forced in the default suite by making
current-dbs.txtgroup-writable and logging the rspamd message tomail.errbefore the tests run. Without the fixes exactly those two tests fail (138/140), with them 140/140.The
mail.errtest still fails when the file holds another error.The race and test-fix checks ran before the last change to
_parent/run, which only hidesnc's output.