Modified flush_transaction to reconnect to mysql db if necessary. Modified scan_engine to reconnect to PVs if necessary.