This isn't database corruption, this is caused by partially upgraded schema. This is usually caused when an upgrade is aborted or failed during a previous attempt. You should make sure that you completely restore to the previous version including the database schema.
In this case we have a script that will get you past a mid-upgrade failure. Steps to recover are
- Upgrade to 5.0.4
- Run fix script only if upgrade fails.
- Rerun zmsetup.pl after running the fix script
The fix script will fix the schema for the individual schema upgrade that is failing. Rerunning zmsetup.pl after that script will finish the upgrade process.
To run the fix script, download the attachment
http://bugzilla.zimbra.com/attachment.cgi?id=9590
Save the attachment in /opt/zimbra/libexec/scripts/imapfix.pl
Make sure you logged in as zimbra (su - zimbra)
cd /opt/zimbra/libexec/scripts
perl ./imapfix.pl