This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 160317 - Problems with cyrus-imap after upgrading to FC4 from FC3
Problems with cyrus-imap after upgrading to FC4 from FC3
Status: CLOSED INSUFFICIENT_DATA
Product: Fedora
Classification: Fedora
Component: cyrus-imapd (Show other bugs)
4
i686 Linux
medium Severity high
: ---
: ---
Assigned To: Petr Rockai
Brian Brock
:
: 160748 322451 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-14 08:03 EDT by Joon Martin Hansen
Modified: 2008-05-13 09:09 EDT (History)
14 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-02-16 11:50:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Joon Martin Hansen 2005-06-14 08:03:05 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412

Description of problem:
After upgrading to FC4 from FC3 I have problems with starting cyrus-imap. I get this output in the /
var/log/maillog:
Jun 14 13:42:00 storm master[21972]: process started
Jun 14 13:42:00 storm master[21974]: about to exec /usr/lib/cyrus-imapd/ctl_cyrusdb
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: DBERROR ¤6^H^H: db4
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: recovering cyrus databases
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: skiplist: recovered /var/lib/imap/mailboxes.db (53 records, 
14924 bytes) in 0 seconds
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: skiplist: recovered /var/lib/imap/annotations.db (0 records, 
144 bytes) in 0 seconds
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: DBERROR ¤6^H^H: db4
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: DBERROR ¤6^H^H: db4
Jun 14 13:42:00 storm ctl_cyrusdb[21974]: DBERROR: critical database situation
Jun 14 13:42:00 storm master[21972]: process 21974 exited, status 75
Jun 14 13:42:00 storm master[21972]: ready for work
Jun 14 13:42:00 storm master[21975]: about to exec /usr/lib/cyrus-imapd/ctl_cyrusdb
Jun 14 13:42:00 storm master[21976]: about to exec /usr/lib/cyrus-imapd/imapd
Jun 14 13:42:00 storm imap[21976]: DBERROR ^DA^K^H: db4
Jun 14 13:42:00 storm imap[21976]: DBERROR: critical database situation
Jun 14 13:42:00 storm master[21977]: about to exec /usr/lib/cyrus-imapd/imapd
Jun 14 13:42:00 storm imaps[21977]: DBERROR ^DA^K^H: db4
Jun 14 13:42:00 storm imaps[21977]: DBERROR: critical database situation
...

I had no problems with the old cyrus (FC3). 

Version-Release number of selected component (if applicable):
cyrus-imapd-2.2.12-6.fc4, db4-4.3.27-3

How reproducible:
Always

Steps to Reproduce:
1. Install and configure cyrus-imap on FC3
2. Upgrade to FC4
3. Then the problem occurred in my environment.
  

Actual Results:  I have not actually done this...

Additional info:

/etc/imapd.conf
configdirectory: /var/lib/imap
partition-default: /home/imap
admins: cyrus root
altnamespace: 1
sievedir: /home/imap/sieve
sieve_maxscriptsize: 32
sieve_maxscripts: 5
sendmail: /usr/sbin/sendmail
hashimapspool: false
reject8bit: no
sasl_pwcheck_method: saslauthd
sasl_mech_list: PLAIN
tls_cert_file: /usr/share/ssl/certs/cyrus-imapd.pem
tls_key_file: /usr/share/ssl/certs/cyrus-imapd.pem
tls_ca_file: /usr/share/ssl/certs/ca-bundle.crt
unixhierarchysep: 1
Comment 1 Nathan G. Grennan 2005-06-14 10:48:17 EDT
I did a quick search with google and it looks like there is likely a way to get
db 4.3 to work. You run some commands with db 4.2 against the database files,
then upgrade to 4.3.

http://mail-index.netbsd.org/tech-pkg/2005/01/27/0031.html

I am very interested in your results. I have multiple mail servers using
cyrus-imapd under FC3 that I plan to upgrade to FC4.
Comment 2 Joon Martin Hansen 2005-06-14 12:00:04 EDT
Thanks for the feedback, Nathan! -I used another machine and moved the entire imap-config and 
structure over and tried what's written in the URL you sent. I moved the /var/lib/imap back to my server 
and restarted it. Everything seems ok, exept some trouble with some CA sertificates. Again thank you for 
the input!
Comment 3 Nathan G. Grennan 2005-06-14 12:21:17 EDT
You are welcome. Thank you for sharing the results.
Comment 4 Simon Matter 2005-06-15 09:54:20 EDT
A very quick and very dirty way to make things work again looks like this:

rm -rvf /var/lib/imap/db/* /var/lib/imap/db.backup?

This simply removes the BDB logs and backups which have a modified file format
for 4.3. If something goes wrong, the last backup is your friend. It has always
worked for me, YMMW.
Comment 5 John Dennis 2005-06-17 10:53:16 EDT
*** Bug 160748 has been marked as a duplicate of this bug. ***
Comment 6 saul 2005-06-17 18:14:29 EDT
My workaround was brute force:

Delete the database files, move the message hierarchy out
of the way, remove cyrus-imapd, reinstall it fresh,
move the messages back, and reconstruct.

That worked, since I'm my only mail user, but not acceptable
for anything where you've got real users.
Comment 7 Pim Zandbergen 2005-06-20 07:28:59 EDT
You can also fix the database using tools in db-compat:

# service cyrus-imapd stop
# db42_checkpoint -v -1 -h /var/lib/imap/db
# db42_recover -v -h /var/lib/imap/db
# rm -vf /var/lib/imap/db/log.*
# service cyrus-imapd start
Comment 8 John Dennis 2005-06-21 17:45:12 EDT
I believe the steps outlined in comment #7 represent the optimal series of steps
for fixing this problem. However there are a couple of caveats:

The package name is compat-db.

You need to run the version of db_checkpoint and db_recover that the previous
version of cyrus-imapd was built with. The version is encoded in the name, e.g.
db42_checkpoint is Berkely DB 4.2. But how do you know what version the previous
cyrus-imap was built with? It's in the file
/usr/share/doc/cyrus-imapd-*/README.buildoptions, but the doc directory will
have been replaced by the new rpm install, so that's telling you about the
current version. You would have needed to have read this file before upgrading
and since you're reading this bugzilla chances are you already lost that
opportunity. The %pre script should proably be checking this and doing the
checkpoint/recover. I'm looking into that option.

The good news is since we haven't shipped a lot of versions of cyrus-imap the
mapping from cyrus-imap rpm to Berkely DB is trival. If its FC4 its linked
against Berkely 4.3, otherwise for all other Red Hat supplied RPMS its Berkley
DB 4.2. Thus if you're upgrading from any previous release to FC4 then use the
db42_checkpoint, db42_recover commands in the compat-db rpm.

If anyone experiences trouble with the method in comment #7 I would like to know
about it as soon as possible because it will proably be folded into the spec
file for upgrades and a new release made so others are not bitten by this.
Comment 9 Rob K 2005-06-22 02:56:23 EDT
I get:

db42_checkpoint -v -1 -h /var/lib/imap/db
db_checkpoint: Program version 4.2 doesn't match environment version
db_checkpoint: open: Invalid argument

This is after an FC3->FC4 upgrade, using cyrus-imapd frome extras.
Comment 10 Simon Matter 2005-06-22 03:42:50 EDT
John, my real question is why do we have to checkpoint/recover any db files
after cyrus-imapd has been shutdown cleanly? Is there anything kept somewhere
else than in the .db files? I can understand there is something left after a
crash but why after a clean shutdown? But then, I'm not an expert in BDB.

Can some BDB guru answer my question?

I'm quite sure I'll do something else in the upcoming Invoca rpms because
checkpoint/recover does simply not work for those using my rpms. I'll very
likely create backups of all db related files and then remove the logs as
mentioned in my comment #4 so if something goes wrong, one still has the old db
files around to fix things by hand.
Comment 11 John Dennis 2005-06-22 11:32:58 EDT
With respect to comment #10 from Simon:

I'm not a BDB guru either :-) But over the last two days have tried to educate
myself by reading all the BDB doc and the source code in cyrus-imap that uses
BDB (lib/cyrusdb_berkley.c). Here is my current understanding, abeit imperfect,
if other's see errors please correct me.

BDB has upgrade procedures which depend what changed between releases. It is not
an automatic process, BDB does not detect the need to perform the upgrade
procedures, it is up to the installation to do this. The first step in this
process is knowing what changed between the version of the BDB library the
application previously linked with and the version of the BDB library it is
currently linked with. We went from 4.2 to 4.3.

Here is the doc on what changed in 4.3:
http://www.sleepycat.com/docs/ref/upgrade.4.3/disk.html

The only thing that changed in the environment was the log file format (there
were API changes too, but that's not an issue in this instance).

Here is the doc on how perform an upgrade once you know what changed:
http://www.sleepycat.com/docs/ref/upgrade/process.html

You will note it is necessary to know what features of BDB are used by the
application, in particular if its using transactions. Cyrus-imap is using
transactions and logging (see cyrusdb_berkley.c).

BDB uses write ahead logging to implement its transactions. The operations
necessary to commit a transaction is first written to the log file. To assure
the transaction is atomic the state of the database can be queried to see what
operations in the log file were performed and if necessary roll back or roll
forward operations to make sure the database is consistent. This operation is
called recovery. Recovery cannot be performed without the log file.

Checkpointing assures transaction components are flushed to the log file in a
consistent manner. If the application shutdown cleanly checkpointing is not
necessary, however it does not hurt and is considered a safe step.

Just because the application shut down cleanly does not mean outstanding
transactions are cleanly commited to the database. Remember a transaction is a
series of database operations that are meant to appear atomic. Thus it is
possible for a clean shutdown to occur but leave partial transactions in the log
file.

Recovery is what makes the database consistent. The recovery process includes
review of log files and databases to ensure that the changes from each committed
transaction appear in the database, and that no changes from an unfinished (or
aborted) transaction do.

Log files may be specific to a BDB version (in our case they are). Therefore
recovery has to be performed using the version of BDB the log file was written
with. Once recovery is complete the log file can be removed so that a new log
file can be generated by the new version of the BDB library when the new version
of the application starts.

My concern is that if you do just remove the log files without recovery you may
leave the database in an inconsistent state. If log file removal has worked for
you in the past you may have been fortunate or it may just indicate that
cyrus-imap's transactions are not complex with interdepenent transaction components.

After reading a lot of the BDB doc its clear to me that transitioning BDB
versions is not simple nor automatic. A lot of onus is placed on admins, this
does not seem very friendly to me. In the past we've discussed whether BDB
should be packaged with cyrus-imap. We both felt this was a liability and added
needless complexity. However, as I've investigated this more I've learned many
of the major applications which use BDB do in fact package their own version of
BDB and I'm beginning to understand why. BDB makes very few concessions to
version upgrades leaving most of the issues to installations :-(

When performing an upgrade installation it can be seen from above it is
necessary to know the BDB version previously in use. Unfortunately I could not
find anyway to query this information. One cannot use the BDB utilities because
BDB may have been upgraded independently because cyrus-imap and BDB are separate
packages. I can think of only two ways to get the version information.

1) Query the existing log files or database files for version information, in
other words, tell me what version of BDB wrote you? It's a pretty obvious
utility but I couldn't find any way to do it (to the best of my knowledge the -V
option on many of the BDB utilities only tell you about the library version that
utility was linked with). Data files do not seem to have version information
embedded in them (true??).

2) Query the cyrus-imap that is being replaced during the upgrade. There are
several ways to get the BDB version BEFORE the upgrade takes place. Once the
upgrade occurs the information is lost. This is why I'm of the mind at the
moment doing something in %pre is the optimal solution.

This has been a challenging problem to unravel, at least in terms of finding a
solution is robust. I'm leary of operating on assumptions and prefer a solution
that follows the guidelines. It is a shame none of this showed up during the FC4
testing period.
Comment 12 John Dennis 2005-06-22 11:40:36 EDT
With respect to comment # from Rob:

Did you run cyrus-imapd for any length of time after doing the FC4 upgrade? I'm
wondering if DBB 4.3 files got written into the environment by the new version
of cyrus-imapd.
Comment 13 John Dennis 2005-06-22 14:30:36 EDT
FYI, I will be out of the office till 7/4/2005, I am not ignoring this issue.
I've searched info-cyrus archives. I did not find any new information that is
not otherwise present in the bug report.
Comment 14 Rob K 2005-06-22 18:24:39 EDT
Viz comment #12: Yes, I'm afraid I did.
Comment 15 Nathan G. Grennan 2005-06-27 10:41:41 EDT
As per comment #7, I tried the commands during an upgrade from FC3 to FC4. They
seem to have worked perfectly for me.
Comment 16 Mike Eggleston 2005-07-03 20:42:38 EDT
I performed the steps listed in #7 and still have a problem. I restored the
database files from my most recent level 0 backup and re-ran the steps in #7. I
still have problems. What do I try next?

Jul  3 19:35:51 k2 master[4646]: process started
Jul  3 19:35:51 k2 master[4648]: about to exec /usr/lib/cyrus-imapd/ctl_cyrusdb
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: DBERROR: db4
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: recovering cyrus databases
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: skiplist: recovered /var/imap/mailboxes.db
(80 records, 12588 bytes) in 0 seconds
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: skiplist: recovered
/var/imap/annotations.db (0 records, 144 bytes) in 0 seconds
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: DBERROR: db4
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: DBERROR: db4
Jul  3 19:35:52 k2 ctl_cyrusdb[4648]: DBERROR: critical database situation
Jul  3 19:35:52 k2 master[4646]: process 4648 exited, status 75
Jul  3 19:35:52 k2 master[4649]: about to exec /usr/lib/cyrus-imapd/idled
Jul  3 19:35:52 k2 idled[4649]: DBERROR: db4
Jul  3 19:35:52 k2 idled[4649]: DBERROR: critical database situation
Jul  3 19:35:52 k2 master[4646]: process 4649 exited, status 75
Jul  3 19:35:52 k2 master[4646]: ready for work
Jul  3 19:35:52 k2 master[4650]: about to exec /usr/lib/cyrus-imapd/tls_prune
Jul  3 19:35:52 k2 master[4651]: about to exec /usr/lib/cyrus-imapd/cyr_expire
Jul  3 19:35:52 k2 master[4652]: about to exec /usr/lib/cyrus-imapd/ctl_cyrusdb
Jul  3 19:35:52 k2 ctl_cyrusdb[4652]: DBERROR: db4
Jul  3 19:35:52 k2 ctl_cyrusdb[4652]: DBERROR: critical database situation
Jul  3 19:35:52 k2 master[4646]: process 4652 exited, status 75
Jul  3 19:35:52 k2 tls_prune[4650]: DBERROR: db4
Jul  3 19:35:52 k2 tls_prune[4650]: DBERROR: critical database situation
Jul  3 19:35:52 k2 master[4646]: process 4650 exited, status 75
Jul  3 19:35:52 k2 cyr_expire[4651]: DBERROR: db4
Jul  3 19:35:52 k2 cyr_expire[4651]: DBERROR: critical database situation
Jul  3 19:35:52 k2 master[4646]: process 4651 exited, status 75
Jul  3 19:36:13 k2 master[4646]: exiting on SIGTERM/SIGINT
Comment 17 Pim Zandbergen 2005-07-04 05:14:22 EDT
How about including commands, similar to those outlined
in comment #7, to the init script, in the "stop" section?

This may not solve this particular upgrade problem, but
may prevent similar problems in the future.
Comment 18 Mike Eggleston 2005-07-04 07:12:53 EDT
That idea seems a good one. I found my problems from #16. Sometime over the past
upgrades I had created both /var/imap and /var/lib/imap. I kept trying to
recover /var/lib/imap when the most recent stuff is in /var/imap. I was able to
recover /var/imap and am now up and working again.

Thanks for the commands in #7!
Comment 19 Simon Matter 2005-08-22 10:19:56 EDT
As promised incomment #10, I have implemented a solution in our invoca rpms.
Whenever cyrus-imapd is stopped via the sysv init script, all Berkeley databases
are checkpointed, recovered and then exported to skiplist. On startup, databases
which are configured as Berkeley DB are imported from skiplist. This is all done
using the cvt_cyrusdb_all script which is called from the init script. I've put
much work and testing into the whole process and it seems to work fine. For
example I tested the migration from RedHat 7.2 based server to Fedora Core 4. I
simply stopped cyrus-imapd on the RedHat 7.2 box, rsynced /var/lib/imap and
/var/spool/imap over to the new Fedora Core 4 box, and started cyrus-imapd
again. Everything worked as expected.
Comment 20 John Dennis 2005-08-22 10:28:14 EDT
Thank you Simon!!
Comment 21 Angel Lafuente Echeazarra 2006-02-06 07:41:48 EST
In our company, we have migrated a production server from and old server  
(Fedora Core 3) to a new one (Fedora Core 4). We had the same problem with BDB  
version due to distro release upgrade.  
  
We have applied SUCCESSFULLY the procedure suggested in this post into the  
recover process.  
  
After a few tries in our test enviroment, this is our very basic "script". The  
files, obtained from the "backup" are in "/MYDIR/mail".  
  
[root@mymachine mail]# pwd  
/MYDIR/mail  
[root@mymachine mail]# ls  
200602011358_mail.tar  etc  restaura-cyrus-FC3toFC4.sh  var  
  
[root@ mail]# cat restaura-cyrus-FC3toFC4.sh  
  
#!/bin/bash  
# Script to recover cyrus-imapd server from FC 3 to FC 4.  
# The backup files must be recovered in /MYDIR/mail  
# Cyrus-imapd must be stopped.  
  
# Delete default mailbox DB installed by RPMs  
  
rm /var/lib/imap/deliver.db  
rm /var/lib/imap/annotations.db  
rm /var/lib/imap/mailboxes.db  
rm /var/lib/imap/backup/*  
rm /var/lib/imap/db.backup*/*  
rm /var/lib/imap/db/*  
rm /var/lib/imap/log/*  
rm /var/lib/imap/msg/*  
rm /var/lib/imap/proc/*  
rm /var/lib/imap/quota/*  
rm /var/lib/imap/sieve/*  
rm -r /var/lib/imap/user/*  
rm -r /var/spool/imap/*  
  
# Restore from backup  
  
cp -p /MYDIR/mail/var/lib/imap/deliver.db /var/lib/imap/  
cp -p /MYDIR/mail/var/lib/imap/annotations.db /var/lib/imap/  
cp -p /MYDIR/mail/var/lib/imap/mailboxes.db /var/lib/imap/  
cp -p /MYDIR/mail/var/lib/imap/backup/* /var/lib/imap/backup/  
cp -p /MYDIR/mail/var/lib/imap/db/* /var/lib/imap/db/  
cp -p /MYDIR/mail/var/lib/imap/log/* /var/lib/imap/log/  
cp -p /MYDIR/mail/var/lib/imap/msg/* /var/lib/imap/msg/  
cp -p /MYDIR/mail/var/lib/imap/quota/* /var/lib/imap/quota/  
cp -p /MYDIR/mail/var/lib/imap/sieve/* /var/lib/imap/sieve/  
cp -p -R /MYDIR/mail/var/lib/imap/user/* /var/lib/imap/user/  
cp -p -R /MYDIR/mail/var/spool/imap/* /var/spool/imap/  
  
# DB status recover  
  
db42_checkpoint -v -1 -h /var/lib/imap/db  
db42_recover -v -h /var/lib/imap/db  
rm -vf /var/lib/imap/db/log.*  
  
The script output:  
  
[root@mymachine mail]# ./restaura-cyrus-FC3toFC4.sh  
rm: no se puede borrar «/var/lib/imap/db.backup*/*»: No existe el fichero o el  
directorio  
rm: no se puede borrar «/var/lib/imap/log/*»: No existe el fichero o el  
directorio  
rm: no se puede borrar «/var/lib/imap/msg/*»: No existe el fichero o el  
directorio  
rm: no se puede borrar «/var/lib/imap/proc/*»: No existe el fichero o el  
directorio  
rm: no se puede borrar «/var/lib/imap/quota/*»: No existe el fichero o el  
directorio  
rm: no se puede borrar «/var/lib/imap/sieve/*»: No existe el fichero o el  
directorio  
cp: no se puede efectuar `stat' sobre «/MYDIR/mail/var/lib/imap/log/*»: No  
existe el fichero o el directorio  
cp: no se puede efectuar `stat' sobre «/MYDIR/mail/var/lib/imap/msg/*»: No  
existe el fichero o el directorio  
cp: no se puede efectuar `stat' sobre «/MYDIR/mail/var/lib/imap/quota/*»: No  
existe el fichero o el directorio  
cp: no se puede efectuar `stat' sobre «/MYDIR/mail/var/lib/imap/sieve/*»: No  
existe el fichero o el directorio  
db_checkpoint: checkpoint: Fri Jan 27 09:56:05 2006  
  
db_recover: Finding last valid log LSN: file: 1 offset 776504  
db_recover: Recovery starting from [1][776299]  
db_recover: Recovery complete at Fri Jan 27 09:56:13 2006  
db_recover: Maximum transaction ID 80000011 Recovery checkpoint [1][776605]  
«/var/lib/imap/db/log.0000000001» borrado  
  
A warning should be included into distro release notes about this issue. For  
example, the same will happen when someone upgrade from FC3 to FC5.  
  
Thank you. 
Comment 22 petrosyan 2008-02-16 11:50:45 EST
Fedora Core 4 is no longer maintained.

Setting status to "INSUFFICIENT_DATA". If you can reproduce this bug in the
current Fedora release, please reopen this bug and assign it to the
corresponding Fedora version.
Comment 23 Dan Horák 2008-05-13 09:09:41 EDT
*** Bug 322451 has been marked as a duplicate of this bug. ***

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