Fixed some possible bug on locks when doing a transaction with invalid transaction number.