@testing.requires.two_phase_transactions
@testing.requires.two_phase_recovery
def test_two_phase_recover(self):
    users = self.tables.users
    connection = testing.db.connect()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), dict(user_id=1, user_name='user1'))
    transaction.prepare()
    connection.invalidate()
    with testing.db.connect() as connection2:
        eq_(connection2.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [])
    with testing.db.connect() as connection2:
        recoverables = connection2.recover_twophase()
        assert (transaction.xid in recoverables)
        connection2.commit_prepared(transaction.xid, recover=True)
        eq_(connection2.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [(1,)])
@testing.requires.two_phase_transactions
@testing.requires.two_phase_recovery
def test_two_phase_recover(self):
    users = self.tables.users
    connection = testing.db.connect()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), dict(user_id=1, user_name='user1'))
    transaction.prepare()
    connection.invalidate()
    with testing.db.connect() as connection2:
        eq_(connection2.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [])
    with testing.db.connect() as connection2:
        recoverables = connection2.recover_twophase()
        assert (transaction.xid in recoverables)
        connection2.commit_prepared(transaction.xid, recover=True)
        eq_(connection2.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [(1,)])