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

Re: (ITS#5391) hdb deadlock

hyc@symas.com writes:
>Hallvard B Furuseth wrote:
>> How about making #bytes-based checkpoints signal or (pthread_kill?) the
>> timed checkpoints thread, so that thread can handle all checkpoints?
> It's an interesting idea. But that means we have to count bytes ourselves,
> rather than letting BerkeleyDB do it.

Whoops, good point.

> Personally I don't think byte counts are very useful here. They're made
> somewhat superfluous because the data volume will tend to cause the
> transaction log buffers to fill up and be flushed regardless.

I don't think Berkeley DB writes a checkpoint record then, at least I
don't see that in the docs.  If not, #bytes do help keep recovery and
checkpoint times down.

Anyway, unless you are proposing to ignore the #bytes parameter: If this
is a Berkeley DB bug we could hear what they say, and in the meantime
put a mutex_trylock around checpoints.  Unless db has some feature which
defeats that, like if txn_checkpoint() merely schedules a checkpoint.

#define CHECKPOINT_WORKAROUND /* hopefully an ITS#5391 workaround */

struct bdb_info {
#	ldap_pvt_thread_mutex_t	bi_checkpoint_mutex;
#define	CHECKPOINT_LOCK(op, bdb) op(&(bdb)->bi_checkpoint_mutex)
#define	CHECKPOINT_LOCK(op, bdb) 0

#define TXN_CHECKPOINT(bdb, k, m, f) do { \
	if ( CHECKPOINT_LOCK( ldap_pvt_thread_mutex_trylock, bdb ) == 0 ) { \
		(bdb)->bi_dbenv->txn_checkpoint( (bdb)->bi_dbenv, k, m, f ); \
		(void) CHECKPOINT_LOCK( ldap_pvt_thread_mutex_unlock, bdb ); \
	} \
} while (0)