[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: back-bdb deadlocks?



David Boreham wrote:
For this current approach to work without interfering with db_archive, we need a way to tell BDB that these transactions are read-only...

What you are looking for here is Isolation Level 2.

DB does not currently implement this.

But the next major release will.

Next major = 5.xx?

It turns out that a simple patch to BDB is all that's needed (see attached).

The corresponding patch to back-bdb is just this:

Index: cache.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/back-bdb/cache.c,v
retrieving revision 1.78
diff -u -r1.78 cache.c
--- cache.c     12 Jul 2004 18:02:24 -0000      1.78
+++ cache.c     17 Jul 2004 16:38:15 -0000
@@ -1186,7 +1186,7 @@

if ( ldap_pvt_thread_pool_getkey( ctx, ((char *)env)+1, &data, NULL ) ) {
for ( i=0, rc=1; rc != 0 && i<4; i++ ) {
- rc = TXN_BEGIN( env, NULL, txn, 0 );
+ rc = TXN_BEGIN( env, NULL, txn, DB_TXN_NOT_DURABLE );
if (rc) ldap_pvt_thread_yield();
}
if ( rc != 0) {




--
  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support
Index: dbinc/db.in
===================================================================
RCS file: /var/CVSROOT/bdb42/dbinc/db.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- dbinc/db.in	25 Nov 2003 21:58:02 -0000	1.1.1.1
+++ dbinc/db.in	17 Jul 2004 16:07:23 -0000	1.2
@@ -839,6 +839,7 @@
 #define	TXN_NOWAIT	0x040		/* Do not wait on locks. */
 #define	TXN_RESTORED	0x080		/* Transaction has been restored. */
 #define	TXN_SYNC	0x100		/* Sync on prepare and commit. */
+#define	TXN_NOLOG	0x200		/* Do not log this transaction. */
 	u_int32_t	flags;
 };
 
Index: txn/txn.c
===================================================================
RCS file: /var/CVSROOT/bdb42/txn/txn.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- txn/txn.c	17 Dec 2003 21:43:53 -0000	1.1.1.2
+++ txn/txn.c	17 Jul 2004 16:07:27 -0000	1.2
@@ -127,7 +127,7 @@
 	if ((ret = __db_fchk(dbenv,
 	    "txn_begin", flags,
 	    DB_DIRTY_READ | DB_TXN_NOWAIT |
-	    DB_TXN_NOSYNC | DB_TXN_SYNC)) != 0)
+	    DB_TXN_NOSYNC | DB_TXN_SYNC | DB_TXN_NOT_DURABLE)) != 0)
 		return (ret);
 	if ((ret = __db_fcchk(dbenv,
 	    "txn_begin", flags, DB_TXN_NOSYNC, DB_TXN_SYNC)) != 0)
@@ -193,6 +193,8 @@
 		F_SET(txn, TXN_SYNC);
 	if (LF_ISSET(DB_TXN_NOWAIT))
 		F_SET(txn, TXN_NOWAIT);
+	if (LF_ISSET(DB_TXN_NOT_DURABLE))
+		F_SET(txn, TXN_NOLOG);
 
 	if ((ret = __txn_begin_int(txn, 0)) != 0)
 		goto err;
@@ -328,7 +330,7 @@
 	 * We should set this value when we write the first log record, not
 	 * here.
 	 */
-	if (DBENV_LOGGING(dbenv))
+	if (DBENV_LOGGING(dbenv) && !F_ISSET(txn, TXN_NOLOG))
 		__log_txn_lsn(dbenv, &begin_lsn, NULL, NULL);
 	else
 		ZERO_LSN(begin_lsn);