Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.

Will backport.
5 files changed