on intermediate_report generation retry query after reconnecting the database