Hi,
So I ran into this issue again and wanted to run my solution by you in
case it seemed correct. What I did was change this line in BerkeleyDB.xs:
(db->Status = ((db->dbp)->associate)(db->dbp, NULL, sec->dbp, &cb, flags))
to this:
(db->Status = ((db->dbp)->associate)(db->dbp, db->txn, sec->dbp, &cb,
flags))
The problem I had occurred when in a transaction I updated a database
and then created a secondary index for it. Both the database and the
secondary index were stored in the same file. Because Berkeley DB
creates a transaction for the associate call if none is specified, the
scenario resulted in two transactions competing for a write lock on page
0 of the database resulting in a self deadlock. The change above just
means that the associate is run in the same transaction as the update so
no deadlock. I can't see any problems with this change - it appears to
be an optimization - but perhaps it's adding a limitation that I don't
see. My alternate approach was going to be to add a transaction argument
to the Perl associate interface which would certainly be more general
though maybe unnecessarily so.
Best,
Mike