Fix regression on after_commit in nested transactions. (master)

related to #16432 .

[fixes #16425]

This is practically a backport of that fix, plus 1 commit to make it work.

This is to ensure the same behaviour as 3.2
I can actually, pretty simply, explain this change:
So there are 3 changes
 - Rollback method: It will pop the transaction and rollback afterwards. Thats good because the ensure code will be just no-op, as the `error` var is set.
- Commit method: it will also pop and call commit. If there is an error on that call, the `rescue` call will not pop anymore, as this had already pop the stack.
- Remove `@stack.pop` in the end. As the rollback or the commit will pop the stack already, we should not pop it again.