Re: [Exim] failed to open DB file

Góra strony
Delete this message
Reply to this message
Autor: Steve Haslam
Data:  
Dla: exim-users
Temat: Re: [Exim] failed to open DB file
On Tue, Oct 08, 2002 at 10:38:49PM +0100, Steve Haslam wrote:
> On Tue, Oct 08, 2002 at 04:30:14PM -0400, Neal D. Becker wrote:
> > It's absolutely repeatable. Every time I send _outgoing_ mail. Never
> > on incoming mail.
>
> Have you tried simply deleting the DB file and seeing if it gets recreated
> OK?
>
> DB libraries give very vague errno values when opening databases, sadly.


This patch will produce more helpful error messages for berkeley db 3-
sadly, you can set up an error callback function before trying to open a
file with version 2, unless you use an environment object. Which is maybe
not a bad thing, but by then you might as well write bdb-specific versions
of dbfn_open() etc. to use bdb's locking functions too :)

Index: dbstuff.h
===================================================================
RCS file: /var/local/cvs/exim/exim/src/dbstuff.h,v
retrieving revision 1.2
diff -u -r1.2 dbstuff.h
--- dbstuff.h    3 Oct 2002 10:13:54 -0000    1.2
+++ dbstuff.h    9 Oct 2002 13:57:17 -0000
@@ -129,10 +129,11 @@
 /* EXIM_DBOPEN - sets *dbpp to point to an EXIM_DB, NULL if failed */
 #define EXIM_DBOPEN(name, flags, mode, dbpp)         \
        if (db_create(dbpp, NULL, 0) != 0 || \
-         (*dbpp)->open(*dbpp, CS name, NULL, \
-         ((flags) == O_RDONLY)? DB_UNKNOWN : DB_HASH, \
-         ((flags) == O_RDONLY)? DB_RDONLY : DB_CREATE, \
-         mode) != 0) *(dbpp) = NULL
+          ((*dbpp)->set_errcall(*dbpp, dbfn_bdb_error_callback), \
+          (*dbpp)->open(*dbpp, CS name, NULL, \
+          ((flags) == O_RDONLY)? DB_UNKNOWN : DB_HASH, \
+          ((flags) == O_RDONLY)? DB_RDONLY : DB_CREATE, \
+          mode)) != 0) *(dbpp) = NULL


 /* EXIM_DBGET - returns TRUE if successful, FALSE otherwise */
 #define EXIM_DBGET(db, key, data)      \
Index: dbfn.c
===================================================================
RCS file: /var/local/cvs/exim/exim/src/dbfn.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dbfn.c
--- dbfn.c    22 Jul 2002 08:59:48 -0000    1.1.1.1
+++ dbfn.c    9 Oct 2002 13:57:17 -0000
@@ -31,7 +31,19 @@
 arrange to hold the locks for the bare minimum of time. */



+/* SRH:
+ For Berkeley DB >= 2, we can define a function to be called in case of DB errors
+ This should help with debugging strange DB problems, e.g. getting "File exists" when you try to open a db file
+*/
+
+#if defined(USE_DB) && defined(DB_VERSION_STRING)
+
+static void dbfn_bdb_error_callback(const char *pfx, char *msg)
+{
+ log_write(0, LOG_MAIN, "DB error: %s", msg);
+}

+#endif

 /*************************************************
 *          Open and lock a database file         *
@@ -138,7 +150,6 @@


/* If the open has failed, return NULL, leaving errno set. If lof is TRUE,
log the event - also for debugging - but not if the file just doesn't exist. */
-
if (dbblock->dbptr == NULL)
{
int save_errno = errno;
@@ -158,6 +169,10 @@

DEBUG(D_hints_lookup) debug_printf("opened hints database %s: flags=%x\n", buffer,
flags);
+
+#if defined(USE_DB) && defined(DB_VERSION_STRING)
+ dbblock->dbptr->set_errcall(dbblock->dbptr, dbfn_bdb_error_callback);
+#endif

/* All is well. However, if we are running as root and this is the first
access to the database, its files will be owned by root. We want them to

--
Steve Haslam      Reading, UK                           araqnid@???
Debian GNU/Linux Maintainer                               araqnid@???
but I won't admit to needing you
I'll never say that's true, not to you                  [sister machine gun]