avoid leaking transactions - merged changeset 12836 from 4.2