Commit d1077863 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

fixes to database functions: do not delete from recover_activities and recover_operations

parent f30c0cf9
......@@ -81,7 +81,6 @@ void CaSupDbActivity::init()
void CaSupDbActivity::execute() {
bool ok;
printf(" [0x%lx ] CaSupDbActivity.execute enter\n", pthread_self());
if(!d->error) {
while(!d->quit) {
......@@ -100,7 +99,6 @@ void CaSupDbActivity::execute() {
for(CaSupDbAEvent *e : events) {
CaSupDbFuncs dbf;
printf(" [0x%lx ] CaSupDbActivity.execute: new event\n", pthread_self());
if(e->type == CaSupDbAEvent::RecoverEv) {
dbf.set_last_recover_successful(d->dbh, e->success);
printf("[0x%lx ] CaSupDbActivity::execute %s : ", pthread_self(), e->success ? "\e[1;32mrecover successful" : "\e[1;31mrecover failed" );
......@@ -120,7 +118,6 @@ void CaSupDbActivity::execute() {
ok = dbf.remove_from_recovery(d->dbh, e->datalist);
}
printf("CaSubDbActivity.execute \e[1;32mIN CASE OF SUCCESSFUL RESTORE sent restore for %ld activities\e[0m\n", e->datalist.size());
}
else if (e->type == CaSupDbAEvent::DbQueryEv) {
const std::list<CuData> &dali = e->datalist;
......
......@@ -318,15 +318,15 @@ bool CaSupDbFuncs::remove_from_recovery(CaDbH *h, int srv_id) {
// get all the operation IDs associated to srv_id
std::string stm = "SELECT operation_id FROM recover_activities WHERE from_srv_conf="
"(SELECT conf_id FROM service WHERE id=$1)";
if(!res.error()) // begin transaction successful
res = h->execute(stm, std::vector<std::string> { std::to_string(srv_id) });
// now delete from recover_activities and recover_operations by operation_id
for(int i = 0; !res.error() && i < res.size(); i++) {
const std::string& opid = res.value(0, "operation_id");
res = h->execute("DELETE FROM recover_activities WHERE operation_id=$1", std::vector<std::string> { opid });
if(!res.error())
res = h->execute("DELETE FROM recover_operations WHERE id=$1", std::vector<std::string> { opid });
}
// if(!res.error()) // begin transaction successful
// res = h->execute(stm, std::vector<std::string> { std::to_string(srv_id) });
// // now delete from recover_activities and recover_operations by operation_id
// for(int i = 0; !res.error() && i < res.size(); i++) {
// const std::string& opid = res.value(0, "operation_id");
// res = h->execute("DELETE FROM recover_activities WHERE operation_id=$1", std::vector<std::string> { opid });
// if(!res.error())
// res = h->execute("DELETE FROM recover_operations WHERE id=$1", std::vector<std::string> { opid });
// }
if(!res.error()) {
stm = "DELETE FROM recovery WHERE srv_id=$1";
res = h->execute(stm, std::vector<std::string> { std::to_string(srv_id) });
......@@ -354,12 +354,12 @@ bool CaSupDbFuncs::remove_from_recovery(CaDbH *h, const std::list<CuData> &datal
}
}
} // for datali
for(const std::string& opid : opids) {
if(!res.error())
res = h->execute("DELETE FROM recover_activities WHERE operation_id=$1", std::vector<std::string> {opid});
if(!res.error())
res = h->execute("DELETE FROM recover_operations WHERE id=$1", std::vector<std::string> {opid});
}
// for(const std::string& opid : opids) {
// if(!res.error())
// res = h->execute("DELETE FROM recover_activities WHERE operation_id=$1", std::vector<std::string> {opid});
// if(!res.error())
// res = h->execute("DELETE FROM recover_operations WHERE id=$1", std::vector<std::string> {opid});
// }
for(const std::string& srvco : srvconfs) {
if(!res.error())
res = h->execute("DELETE FROM recovery WHERE srv_id=(SELECT id FROM service WHERE conf_id=$1)",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment