JBTM-2287 It was possible that xa_end is called twice for an xaresource if
a call to prepare fails

- backport from master to 4.17