Skip to content

Commit 161fb2f

Browse files
committed
FTS-1882: Fail multiple replica archiving jobs when archive monitoring step fails
1 parent b80a514 commit 161fb2f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/db/mysql/MySqlAPI.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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();

src/db/mysql/MySqlAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class MySqlAPI : public GenericDbIfce
360360
std::string newFileState, std::string transferMessage, int processId, double filesize, double duration, bool retry,
361361
std::string fileMetadata = "");
362362

363-
bool updateJobTransferStatusInternal(soci::session& sql, std::string jobId, const std::string state);
363+
bool updateJobTransferStatusInternal(soci::session& sql, std::string jobId, const std::string& state);
364364

365365
bool resetForRetryStaging(soci::session& sql, uint64_t fileId, const std::string & jobId, bool retry, int& times);
366366

0 commit comments

Comments
 (0)