Commit 1f6d797e authored by Claes Sjofors's avatar Claes Sjofors Committed by Claes Sjöfors

sev eventstatus set to 0 at upgrade, reconnect of garbage thread added

parent fb76cf77
......@@ -1143,11 +1143,13 @@ void* sev_server::send_histdata_thread(void* arg)
memcpy((char*)&msg->Data + sizeof(pwr_tTime) * rows, vbuf,
sev->m_db->m_items[item_idx].attr[0].size * rows);
}
if (!qcom_Put(&sts, &tgt, &put)) {
qcom_Free(&sts, put.data);
if (!qcom_Put(&lsts, &tgt, &put)) {
qcom_Free(&lsts, put.data);
}
if (ODD(sts)) {
free(tbuf);
free(vbuf);
}
free(tbuf);
free(vbuf);
if (sev->m_read_threads)
sev->m_db->delete_thread(thread);
......@@ -1498,6 +1500,7 @@ void* sev_server::garbage_collector_thread(void* arg)
void* thread = 0;
pwr_tTime next_garco, currenttime;
pwr_tDeltaTime garco_interval;
unsigned int reconnect_cnt = 0;
sev_server* sev = (sev_server*)arg;
......@@ -1513,6 +1516,14 @@ void* sev_server::garbage_collector_thread(void* arg)
time_GetTime(&currenttime);
if (time_Acomp(&currenttime, &next_garco) == 1) {
sev->garbage_collector(thread);
if (sev->m_sts == SEV__NOCONNECTION) {
if ( reconnect_cnt < 50) {
errh_Error("Database connection lost, thread garbage collector, reconnecting");
thread = sev->m_db->new_thread();
reconnect_cnt++;
}
}
time_FloatToD(&garco_interval, sev->m_config->GarbageInterval);
time_Aadd(&next_garco, &next_garco, &garco_interval);
......@@ -1549,6 +1560,8 @@ void sev_server::garbage_collector(void* thread)
scan_cnt = 0;
garbage_item(thread, current);
if (m_sts == SEV__NOCONNECTION)
return;
current++;
if (current >= item_size)
......
......@@ -651,6 +651,17 @@ int sev_dbms_env::updateDBToSevVersion5(void)
printf("%s: %s\n", __FUNCTION__, mysql_error(con()));
return 0;
}
sprintf(query,
"update %s set eventstatus=0",
tablename);
rc = mysql_query(con(), query);
if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf("%s: %s\n", __FUNCTION__, mysql_error(con()));
return 0;
}
}
mysql_free_result(result);
......@@ -2948,7 +2959,10 @@ int sev_dbms::delete_old_data(pwr_tStatus* sts, void* thread, char* tablename,
if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf("Delete old data: %s\n", mysql_error(con));
*sts = SEV__DBERROR;
if ( con->net.last_errno == CR_SERVER_GONE_ERROR)
*sts = SEV__NOCONNECTION;
else
*sts = SEV__DBERROR;
return 0;
}
......@@ -5108,7 +5122,6 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid,
e.eventstatus = strtoul(row[j++], 0, 10);
list.push_back(e);
}
printf("ecnt %ld\n", list.size());
mysql_free_result(result);
*sts = SEV__SUCCESS;
......
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