Re: [exim] exim snapshot with sqlite on openbsd ...

Pàgina inicial
Delete this message
Reply to this message
Autor: David Woodhouse
Data:  
A: Kelley Reynolds
CC: Exim Mailing List
Assumpte: Re: [exim] exim snapshot with sqlite on openbsd ...
On Thu, 2005-08-04 at 13:05 -0400, Kelley Reynolds wrote:
> I think what Wild means is that the database gets locked during a
> transaction so that if you were to execute a query during this locked
> period, it wouldn't get executed, but instead say 'Hey, the database
> is locked'. I've used sqlite with ${run} before and the command-line
> version will say 'database is locked' then exit without executing a
> query. Probably what is required is to retry a certain number of
> times or somehow queue the queries such that if the database is
> locked (it's a single file, btw), it will wait until it's not locked
> anymore (which is what I did with a wrapper script)


Hm. I had assumed the same as Phil, but upon closer investigation I see
that by default sqlite will return SQLITE_BUSY immediately on lock
contention. Let's give it a timeout and make that timeout configurable.
5 seconds by default.

--- exim-snapshot/src/lookups/sqlite.c.orig    2005-08-04 23:52:45.000000000 +0100
+++ exim-snapshot/src/lookups/sqlite.c    2005-08-05 00:00:19.000000000 +0100
@@ -36,6 +36,7 @@ if (ret != 0)
   debug_printf("Error opening database: %s\n", *errmsg);
   }


+sqlite3_busy_timeout(db, 1000 * sqlite_lock_timeout);
return db;
}

--- exim-snapshot/src/globals.c.orig    2005-08-04 23:56:52.000000000 +0100
+++ exim-snapshot/src/globals.c    2005-08-04 23:58:07.000000000 +0100
@@ -87,6 +87,10 @@ uschar *oracle_servers         = NULL;
 uschar *pgsql_servers          = NULL;
 #endif


+#ifdef LOOKUP_SQLITE
+int sqlite_lock_timeout        = 5;
+#endif
+
 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
 BOOL    move_frozen_messages   = FALSE;
 #endif
--- exim-snapshot/src/globals.h.orig    2005-08-04 23:58:13.000000000 +0100
+++ exim-snapshot/src/globals.h    2005-08-04 23:58:49.000000000 +0100
@@ -51,6 +51,10 @@ extern uschar *oracle_servers;         /
 extern uschar *pgsql_servers;          /* List of servers and connect info */
 #endif


+#ifdef LOOKUP_SQLITE
+extern int sqlite_lock_timeout;
+#endif
+
 #ifdef SUPPORT_MOVE_FROZEN_MESSAGES
 extern BOOL    move_frozen_messages;   /* Get them out of the normal directory */
 #endif
--- exim-snapshot/src/readconf.c.orig    2005-08-04 23:59:12.000000000 +0100
+++ exim-snapshot/src/readconf.c    2005-08-05 00:00:04.000000000 +0100
@@ -339,6 +339,9 @@ static optionlist optionlist_config[] = 
 #endif
   { "split_spool_directory",    opt_bool,        &split_spool_directory },
   { "spool_directory",          opt_stringptr,   &spool_directory },
+#ifdef LOOKUP_SQLITE
+  { "sqlite_lock_timeout",      opt_int,         &sqlite_lock_timeout },
+#endif
 #ifdef EXPERIMENTAL_SRS
   { "srs_config",               opt_stringptr,   &srs_config },
   { "srs_hashlength",           opt_int,         &srs_hashlength },




>

--
dwmw2