Bug 3017 - Amavisd does not start up after an unclean shutdown
Summary: Amavisd does not start up after an unclean shutdown
Status: RESOLVED INVALID
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 1
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Sysadmin Team
QA Contact: QA Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-11 11:59 CEST by Derek Jennings
Modified: 2012-01-29 10:56 CET (History)
5 users (show)

See Also:
Source RPM: amavisd-new-2.6.4-9.mga1.src.rpm
CVE:
Status comment:


Attachments
Patch to amavisd init script to delete stale pid file. (833 bytes, patch)
2011-10-19 05:07 CEST, Dave Hodgins
Details | Diff

Description Derek Jennings 2011-10-11 11:59:02 CEST
Description of problem:
If a server running amavisd is restarted after an unclean shutdown amavisd will recognise the stale pid file but will not clear it and will not start.


Version-Release number of selected component (if applicable):
amavisd-new-2.6.4-9.mga1

The bug was fixed upstream in version 2.6.5
From the changelog for 2.6.5
"- treat an empty PID file or a junk one-liner file the same as a nonexistent
  PID file; previously an empty PID file (e.g. after an unclean shutdown)
  would prevent amavisd from starting; problem reported by Michael Scheidell;"

Version 2.6.6 also has bug fixes and the latest stable version is 2.7.0
Manuel Hiebel 2011-10-12 12:27:44 CEST

Assignee: bugsquad => thomas

Comment 1 Thomas Spuhler 2011-10-13 07:09:52 CEST
Cauldron has 2.7.0. 
We don't want put a new version in a stable release.
I may put 2.6.5 into backports

Status: NEW => ASSIGNED

Comment 2 Remco Rijnders 2011-10-17 09:39:11 CEST
Perhaps it's possible to apply (just) the fix to version 2.6.4 and release that as an update?
Comment 3 Thomas Spuhler 2011-10-18 07:04:01 CEST
I found a patch and it works here. But a did a lot of changes on my box. Can ypu please check the location of your amavis.pid file
I have /var/amavis/amavis.pid
Comment 4 Derek Jennings 2011-10-18 14:39:19 CEST
No, It is /var/lib/amavis/amavisd.pid
Comment 5 Dave Hodgins 2011-10-19 05:07:06 CEST
Created attachment 978 [details]
Patch to amavisd init script to delete stale pid file.

The attached patch will delete a stale pid file.

I just installed amavisd-new.  I found it wouldn't start ...
Oct 18 22:27:02 hodgins amavis[26227]: (!)Net::Server: 2011/10/18-22:27:02 Can't connect to TCP port 10025 on 127.0.0.1 [Address already in use]\n  at line 88 in file /usr/lib/perl5/vendor_perl/5.12.2/Net/Server/Proto/TCP.pm

# lsof -n|grep 10025
master    26627             root   88u     IPv4    1094805         0t0        TCP 127.0.0.1:10025 (LISTEN)

So I stopped postfix, and was then able to start amavisd.

I didn't have the problem when I was qa testing kolab, as it
uses cyrus.  I switched back to postfix, after I finished testing
kolab.

Can the default port for amavisd be changed easily?
Comment 6 Thomas Spuhler 2011-10-19 07:48:41 CEST
submitted the stale PID  resolve to updates_testing. please test and I will submit to Qa
Comment 7 Derek Jennings 2011-10-19 12:10:28 CEST
Thanks Thomas
Almost right

Test procedure
--------------

Start amavisd, observe pid file in /var/lib/amavis/amavisd.pid
Stop amavisd gracefully with
service amavisd stop
Observe the pid file is gone.

Now start amavisd again, then kill the amavisd process
Start amavisd again.

Message is:
# service amavisd start
/etc/init.d/amavisd: line 46: checkproc: command not found
(stale amavisd pid file /var/lib/amavis/amavisd.pid found, removing. Did amavisd crash?)Starting amavisd:

So the patch works correctly apart from the error message 
line 46: checkproc: command not found


checkproc is in Suse, but not in Mageia. The equivalent function in Mageia is the status() function in /etc/init.d/functions  However the startup script works whether checkproc is present or not.

+    # Suse patch ZMI 20100428 check for stale pid file
16	+    if test -f $AMAVIS_PID ; then
17	+        checkproc -p $AMAVIS_PID amavisd
18	+        if test $? -ge 1 ; then
19	+            # pid file is stale, remove it
20	+            echo -n "(stale amavisd pid file $AMAVIS_PID found, removing. Did amavisd crash?)"
21	+            rm -f $AMAVIS_PID
22	+        fi
23	+    fi

line 18 tests the result of line 16 it ignores the result of line 17 which can be removed.
Comment 8 Thomas Spuhler 2011-10-22 19:40:00 CEST
fixed in 9.2.
I tested it with restart and crashed when running and so far all looks good
Thomas Spuhler 2011-10-22 19:50:13 CEST

QA Contact: (none) => qa-bugs

Comment 9 Samuel Verschelde 2011-10-22 19:55:52 CEST
Hi Thomas. If you meant to have the QA team test the update and then have it pushed to all users, you must set the Assignee to qa-bugs@ml.mageia.org (we don't use the QA contact field).

Regards

CC: (none) => stormi

Comment 10 Derek Jennings 2011-10-22 22:30:36 CEST
My apologies Thomas I gave some wrong info in comment 7
Line 18 is testing the numerical result code from Line 17. Since checkproc is not present in Mageia the result code is always 0 and it removes the pid file.

In 9.2 the test never passes and the "stale amavisd pid file" message never appears and the pid file is not removed.

I think this will give the correct operation

    if test -f $AMAVIS_PID ; then
           # pid file is stale, remove it
           gprintf "(stale amavisd pid file %s found, removing. Did amavisd crash?)" "$AMAVIS_PID"
           rm -f $AMAVIS_PID
    fi


However the mystery is that it still seems to work. amavis does not fail when starting even when there is a stale pid file present.
To check if my test procedure was OK I went back to amavisd-new-2.6.4-9.mga1 and I cannot get that to fail, either by crashing amavisd, or by crashing the entire server.

I raised the bug report because my server kept crashing due a failing hard drive, and after each restart amavisd refused to start until I manually deleted the pid file so I am confident there is a problem but cannot replicate it to order :-(
Comment 11 Thomas Spuhler 2011-10-23 00:40:51 CEST
Derek, I actually did test the original and it failed because of a stale PID file.
After adding the patch, it didn't fail but reported a warning. After the latest update, it didn't fail nor was there a warning. I will check it gain.
Comment 12 Thomas Spuhler 2011-10-24 02:13:24 CEST
I checked here without the patch and I see not problem with the stale PID file either. I am sorry, I didn't validate the bug, as I found the patch on the Internet and I experienced the problem before on my server. I guess the version we have in Mageia 1 has this already fixed in Amavis.
Let's close this as invalid and I will revert the spec file in svn and remove the patch. Please reopen if you don't agree.

Status: ASSIGNED => RESOLVED
Resolution: (none) => INVALID

Comment 13 Derek Jennings 2011-10-24 08:23:33 CEST
I agree. If it cannot be replicated then it cannot be fixed. I had already moved the mail server to  more reliable hardware so I am not currently experiencing any difficulty.

Thanks for taking a look at it.
Comment 14 Samuel Verschelde 2011-10-24 09:11:09 CEST
To sysadmins: please remove amavisd-new from core/updates_testing, then close the bug as invalid, as the update is cancelled.

Thanks

Status: RESOLVED => REOPENED
Resolution: INVALID => (none)
Assignee: thomas => sysadmin-bugs

Comment 15 Marja Van Waes 2012-01-28 19:38:59 CET
(In reply to comment #14)
> To sysadmins: please remove amavisd-new from core/updates_testing, then close
> the bug as invalid, as the update is cancelled.
> 
> Thanks

ping?

According to Sophie:

[19:37] <marja> :v amavisd-new -s
<snip>
[19:37] <Sophie> 2.6.4-9.2.mga1 // core-updates_testing-src (Mga, 1, i586), core-updates_testing-src (Mga, 1, x86_64)

CC: (none) => marja11

Comment 16 Dave Hodgins 2012-01-28 23:36:42 CET
Could someone from the sysadmin team DELETE the srpm
amavisd-new-2.6.4-9.2.mga1.src.rpm
from Core Updates Testing.

Once that's done, this bug report should be closed as
resolved, invalid.

CC: (none) => davidwhodgins, sysadmin-bugs

Comment 17 Thomas Backlund 2012-01-29 10:56:03 CET
amavisd-new-2.6.4-9.2.mga1 removed

Status: REOPENED => RESOLVED
CC: (none) => tmb
Resolution: (none) => INVALID


Note You need to log in before you can comment on or make changes to this bug.