# cyrus imap lmtp socket timeout

## selim

Aug 16 03:55:11 startseite4 sm-mta[7956]: k7FEZIJQ006323: to=<vui.olafnguyen@startseite.de>, delay=11:19:52, xdelay=00:05:00, mailer=cyrusv2, pri=121929, relay=localhost, dsn=4.4.2, stat=Deferred: Connection timed out with localhost

Aug 16 03:55:16 startseite4 sm-mta[7947]: k7FF37GR004437: to=<zentowski.ronald@startseite.de>, delay=10:52:07, xdelay=00:05:00, mailer=cyrusv2, pri=121937, relay=localhost, dsn=4.4.2, stat=Deferred: Connection timed out with localhost

I get this timeout from my localhost lmtp socket, created via cyrus imap.

My netstat shows me this: 

unix  2      [ ACC ]     STREAM     LISTENING     8779   /var/imap/socket/lmtp

so the socket seems open. How can I find out why my sendmail get a timeout from this socket. Any way to check the connection?

Another strange thing I've noticed: 

every time I do a "ps aux|grep lmtp" I get this line

cyrus    21744  0.0  0.0      0     0 ?        Z    04:29   0:00 [lmtpd] <defunct>

pid changes every time so it seems lmtp which makes problem, a bug maybe?

Sebastian

----------

## Janne Pikkarainen

Is this a working Cyrus installation, which just suddenly stopped receiving mail? Or a completely new installation? If a previous installation, try to restart Cyrus. I've seen similar situation couple of times and restarting Cyrus should help.

----------

## selim

It was a working cyrus installation, which I updated. After that I've restarted it serveral times and even restarted the whole system but seems to have no effect.

I get this errors from cyrus now in my messages log:

Aug 16 13:01:19 startseite4 master[6585]: service lmtpunix pid 30069 in READY st

ate: terminated abnormally

Aug 16 13:01:19 startseite4 master[6585]: service lmtpunix pid 30070 in READY st

ate: terminated abnormally

Aug 16 13:01:19 startseite4 master[6585]: service lmtpunix pid 30072 in READY st

ate: terminated abnormally

Aug 16 13:01:19 startseite4 lmtpunix[30130]: DBERROR : db4

Aug 16 13:01:19 startseite4 lmtpunix[30133]: DBERROR : db4

----------

## Janne Pikkarainen

Ok. There might be something wrong with your /var/imap/db/ directory. Try these steps and BACKUP YOUR /var/imap/ FIRST.

1. Just to make sure: BACKUP YOUR /var/imap/. I shall not take any responsibility whatsoever.

2. Stop Cyrus with /etc/init.d/cyrus stop.

3. Check your current BerkeleyDB version with emerge -pv db

4. Do this: 

```
cd /var/imap/db

dbX.Y_recover (where X.Y is the BDB version you did see before: for example, for BDB 4.1 you would run db4.1_recover)
```

5. Wait until it finishes.

6. Restart Cyrus with /etc/init.d/cyrus start.

7. See if it works.

----------

## selim

I get this for emerge -pv db:

[ebuild   R   ] sys-libs/db-4.2.52_p2-r1  USE="-bootstrap -doc -java -nocxx -tcl -test" 0 kB

and this when I try to start db4.2_recover:

db_recover: Program version 4.2 doesn't match environment version

----------

## selim

Ok, I've found out that I'm using db 4.3.x and tried "db4.3_recovery in /var/imap/db and got this:

db_recover: Skipping log file log.0000000085: historic log version 8

db_recover: log.0000000086: log file open failed: No such file or directory

db_recover: PANIC: No such file or directory

db_recover: DB_ENV->log_put: 86: DB_RUNRECOVERY: Fatal error, run database recovery

db_recover: dbenv->close: DB_RUNRECOVERY: Fatal error, run database recovery

----------

## Janne Pikkarainen

Maybe you have some old logs in that directory and you have upgraded Cyrus or BerkeleyDB over time. In that situation a previous installation might have been used older version of BDB.

----------

## selim

So what can I do in this case?

----------

## selim

I tried db4.2_recover again, and got no error just the prompt again, is this what it should do?

Ok, I've done it with -v an got this:

db_recover: Finding last valid log LSN: file: 85 offset 4849583

db_recover: Recovery starting from [85][4849459]

db_recover: Recovery complete at Wed Aug 16 16:32:45 2006

db_recover: Maximum transaction ID 80005e36 Recovery checkpoint [85][4849583]

so it seems to work correctly now. But why does it tell me it doesn't match the envirement?Last edited by selim on Wed Aug 16, 2006 2:37 pm; edited 1 time in total

----------

## Janne Pikkarainen

Still in the /var/imap/db/ directory give command db4.3_archive -v. It shows you the log files BDB does NOT need anymore. 

If you are confident about the results and you have a fresh backup of log files, you can remove those files with 

```
db4.3_archive -v | xargs rm
```

 command, of course command given in /var/imap/db/ directory.

----------

## Janne Pikkarainen

Oh, you had replied me while I typed my previous reply!

If db4.2_recover did proceed without errors, that probably was the correct version for your Cyrus. In that case just restarting Cyrus should make it work again.

----------

## selim

sorry, it does not, I get the same error in my messages log:

Aug 16 16:39:17 startseite4 lmtpunix[2057]: DBERROR : db4

Aug 16 16:39:17 startseite4 lmtpunix[2063]: DBERROR : db4

Aug 16 16:39:17 startseite4 master[31393]: service lmtpunix pid 2057 in READY state: terminated abnormally

Aug 16 16:39:17 startseite4 master[31393]: service lmtpunix pid 2063 in READY state: terminated abnormally

Aug 16 16:39:17 startseite4 imap[2064]: DBERROR C      : db4

Aug 16 16:39:17 startseite4 lmtpunix[2065]: DBERROR : db4

Aug 16 16:39:19 startseite4 master[31393]: exiting on SIGTERM/SIGINT

----------

## Janne Pikkarainen

So some database is still a bit rotten. Do you use duplicate suppression? In that case /var/imap/deliver.db can be the one which is corrupted. It's safe (knock, knock) to remove, only consequence being that if some user for any reason receives the exactly same mail again, it will be delivered to user instead of rejecting it. So you might try

```
/etc/init.d/cyrus stop

cd /var/imap

mv deliver.db deliver.db.bak

/etc/init.d/cyrus start
```

----------

## selim

hmm, nothing changed, I've done the rename as you mentioned it but I still have: 

Aug 16 16:47:48 startseite4 master[6536]: service lmtpunix pid 7061 in READY state: terminated abnormally

Aug 16 16:47:48 startseite4 master[6536]: service lmtpunix pid 7062 in READY state: terminated abnormally

Aug 16 16:47:48 startseite4 lmtpunix[7953]: DBERROR : db4

----------

## Janne Pikkarainen

What the...

Do you have any idea when this started? You might want to search for the very first occurence of that DB4 error line and see log lines around it. Sometimes Cyrus does spit out some more verbose output about why it decided to bork.

----------

## selim

I have some errors like this:

Aug 13 03:34:51 startseite4 syslog-ng[6180]: new configuration initialized

Aug 13 03:34:50 startseite4 lmtpunix[3840]: DBERROR db4: Program version 4.2 doe

sn't match environment version

Aug 13 03:34:50 startseite4 lmtpunix[3840]: DBERROR db4: environment not yet ope

ned

Aug 13 03:34:50 startseite4 master[23490]: service lmtpunix pid 3840 in READY st

ate: terminated abnormally

Aug 13 03:34:51 startseite4 lmtpunix[3947]: DBERROR db4: environment not yet ope

ned

Aug 13 03:34:50 startseite4 master[23490]: service lmtpunix pid 3844 in READY st

ate: terminated abnormally

Aug 13 03:34:51 startseite4 lmtpunix[3948]: DBERROR db4: Program version 4.2 doe

sn't match environment version

Aug 13 03:34:51 startseite4 lmtpunix[3948]: DBERROR db4: environment not yet ope

ned

Aug 13 03:34:51 startseite4 lmtpunix[3949]: DBERROR db4: Program version 4.2 doe

sn't match environment version

Aug 13 03:34:51 startseite4 lmtpunix[3949]: DBERROR db4: environment not yet ope

ned

Aug 13 03:34:50 startseite4 master[23490]: service lmtpunix pid 3845 in READY st

seems to be one of the first errors in this case

----------

## Janne Pikkarainen

Ok. It figures. Now please tell me, have you upgraded any software lately? It seems like Cyrus is currently linked against different BDB library version than it actually uses. Re-emerging Cyrus might help.

----------

## selim

I'll try a complete reemerge of cyrus and a complete reemerge of db, we'll see if it works. 

Thank you so far, if I have some more problems I try it again, at this place  :Wink: 

----------

## Janne Pikkarainen

Ok.  :Smile: 

----------

## selim

Ok, reemerge doesn't helped anything.

Some other ideas maybe?

----------

## Janne Pikkarainen

Hmm. My server seems to have db 4.2 installed instead of db 4.3. Maybe you should force Cyrus believe that db 4.2 is used. How that's done, I don't know (yet) ... Google, here I come!

----------

## Janne Pikkarainen

That's odd. Cyrus should work ok with BDB 4.3, too. What does ldd /usr/cyrus/bin/lmtpd return? For me it shows DB 4.2:

```
jaba@myserver ~ % ldd /usr/lib/cyrus/lmtpd 

        linux-gate.so.1 =>  (0xffffe000)

        libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0xb7f78000)

        libdl.so.2 => /lib/libdl.so.2 (0xb7f74000)

        libresolv.so.2 => /lib/libresolv.so.2 (0xb7f62000)

        libdb-4.2.so => /usr/lib/libdb-4.2.so (0x4ac67000)

        libc.so.6 => /lib/tls/libc.so.6 (0xb7e4f000)

        libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7e22000)

        /lib/ld-linux.so.2 (0xb7f9d000)

        libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7e0f000)
```

----------

