md: Fix possible deadlock with multiple mempool allocations.