Given a prepared transaction we remove it's txnid from the global table at the end of the call to __wt_txn_prepare. On __wt_txn_commit we call __wt_txn_release which does the same thing except in the case of prepared transactions.
Now this wouldn't be an issue provided the prepared transaction wasn't being reallocated an id however when we commit the transaction calling __wt_txn_commit it calls __wt_txn_set_timestamp which calls __wt_txn_ts_log which if the flag WT_CONN_LOG_DEBUG is enabled calls __txn_logrec_init which calls ___wt_txn_id_check which then reallocates an id to our prepared txn. As such at the end of the call to __wt_txn_commit we don't clear our new id as our transaction is prepared which leaves an entry in the global table and blocks calls to rollback_to_stable when we're in debug mode.
To reproduce this failure add the following assert to __wt_txn_id_check:
In a debug build.