[PATCH 05/13] More logging of DB errors

Bron Gondwana brong at fastmail.fm
Tue Jan 27 23:15:32 EST 2009


We're seeing some DB errors which are probably quota related,
but the debugging info isn't very clear.  This will make it
much more clear exactly what is wrong!
---
 imap/mboxlist.c |    2 +-
 imap/quota_db.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/imap/mboxlist.c b/imap/mboxlist.c
index f0e9436..5cf0580 100644
--- a/imap/mboxlist.c
+++ b/imap/mboxlist.c
@@ -239,7 +239,7 @@ static int mboxlist_mylookup(const char *name, int *typep,
 	break;
 
     default:
-	syslog(LOG_ERR, "DBERROR: error fetching %s: %s",
+	syslog(LOG_ERR, "DBERROR: error fetching mboxlist %s: %s",
 	       name, cyrusdb_strerror(r));
 	return IMAP_IOERROR;
 	break;
diff --git a/imap/quota_db.c b/imap/quota_db.c
index 96b6720..f63859b 100644
--- a/imap/quota_db.c
+++ b/imap/quota_db.c
@@ -94,6 +94,13 @@ int quota_read(struct quota *quota, struct txn **tid, int wrlock)
 	if (!data ||
 	    sscanf(data, UQUOTA_T_FMT " %d",
 		   &quota->used, &quota->limit) != 2) {
+            char *buf;
+            buf = (char *) xmalloc(sizeof(char) * datalen + 1);
+            memcpy(buf, data, datalen);
+            buf[datalen] = '\0';
+            syslog(LOG_ERR, "DBERROR: parsed bogus quota data <%s> for %s",
+               buf, quota->root);
+            free(buf);
 	    r = CYRUSDB_IOERROR;
 	}
 	break;
@@ -108,7 +115,7 @@ int quota_read(struct quota *quota, struct txn **tid, int wrlock)
     }
 
     if (r) {
-	syslog(LOG_ERR, "DBERROR: error fetching %s: %s",
+	syslog(LOG_ERR, "DBERROR: error fetching quota %s: %s",
 	       quota->root, cyrusdb_strerror(r));
 	return IMAP_IOERROR;
     }
-- 
1.5.6.3



More information about the Cyrus-devel mailing list