@@ -1404,7 +1404,7 @@ bool MySqlAPI::updateJobStatus(const std::string& jobId, const std::string& jobS
14041404}
14051405
14061406
1407- bool MySqlAPI::updateJobTransferStatusInternal (soci::session& sql, std::string jobId, const std::string state)
1407+ bool MySqlAPI::updateJobTransferStatusInternal (soci::session& sql, std::string jobId, const std::string& state)
14081408{
14091409 try
14101410 {
@@ -1438,6 +1438,30 @@ bool MySqlAPI::updateJobTransferStatusInternal(soci::session& sql, std::string j
14381438 if (currentState == " STAGING" && state == " STARTED" )
14391439 return true ;
14401440
1441+ if (jobType == Job::kTypeMultipleReplica && currentState == " ARCHIVING" && state == " FAILED" ) {
1442+ // FTS-1882: Fail multi-replica archiving jobs when archive monitoring step fails
1443+ std::string reason = " Archive monitoring failed in a multiple replica job" ;
1444+
1445+ sql << " SELECT source_se FROM t_file WHERE job_id=:job_id AND file_state='FAILED' LIMIT 1 " ,
1446+ soci::use (jobId), soci::into (sourceSe);
1447+
1448+
1449+ sql.begin ();
1450+ // Update job
1451+ soci::statement stmt = (
1452+ sql.prepare << " UPDATE t_job SET "
1453+ " job_state = :state, job_finished = UTC_TIMESTAMP(), "
1454+ " reason = :reason, source_se = :sourceSe "
1455+ " WHERE job_id = :jobId and job_state NOT IN ('FAILED','FINISHEDDIRTY','CANCELED','FINISHED') " ,
1456+ soci::use (state, " state" ), soci::use (reason, " reason" ),
1457+ soci::use (sourceSe, " sourceSe" ),
1458+ soci::use (jobId, " jobId" ));
1459+ stmt.execute (true );
1460+ sql.commit ();
1461+
1462+ return true ;
1463+ }
1464+
14411465 if (state == " ACTIVE" && jobType == Job::kTypeRegular )
14421466 {
14431467 sql.begin ();
0 commit comments