fix part status not set to finished, added debug prints
This commit is contained in:
parent
3587bd08af
commit
31e6900cfb
1 changed files with 16 additions and 1 deletions
|
|
@ -60,6 +60,8 @@ void Uploader::thread_run() {
|
|||
// program was halted
|
||||
this->interface.wait_for_finished();
|
||||
|
||||
DEBUG_PRINT("Uploader was worken up");
|
||||
|
||||
// so first we check if we should still be running
|
||||
if (!this->interface.running()) break;
|
||||
|
||||
|
|
@ -70,6 +72,10 @@ void Uploader::thread_run() {
|
|||
// we need to make sure the queue wasn't emptied between waiting and getting new data
|
||||
if (queue_empty) continue;
|
||||
|
||||
DEBUG_PRINT("Uploader dequeued new task");
|
||||
|
||||
std::cout << "task id is " << task->id << std::endl;
|
||||
|
||||
// everything is good, upload the given task
|
||||
bool success = this->upload_task(std::move(task));
|
||||
|
||||
|
|
@ -79,12 +85,18 @@ void Uploader::thread_run() {
|
|||
this->interface.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("Task successfully uploaded");
|
||||
}
|
||||
|
||||
DEBUG_PRINT("Uploader is starting the shutdown procedure, waiting for cleanup ready");
|
||||
|
||||
// since worker threads might have been running after we ended
|
||||
// the normal upload loop, we have to clean up after them
|
||||
this->interface.wait_for_cleanup_ready();
|
||||
|
||||
DEBUG_PRINT("Uploader has received go for cleanup");
|
||||
|
||||
// upload all the remaining tasks
|
||||
while (!this->interface.finished_queue_empty()) {
|
||||
|
||||
|
|
@ -94,12 +106,15 @@ void Uploader::thread_run() {
|
|||
// in case there are ever multiple upload threads,
|
||||
// the same issues apply as before
|
||||
if (!queue_empty) {
|
||||
DEBUG_PRINT("Uploading finished task");
|
||||
if (!this->upload_task(std::move(task))) {
|
||||
std::cerr << "Error: Lost database connection for uploading tasks during cleanup. Database integrity might be compromised." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DEBUG_PRINT("Uploader is done");
|
||||
}
|
||||
|
||||
bool Uploader::upload_task(std::unique_ptr<OutputType> task) {
|
||||
|
|
@ -112,7 +127,7 @@ bool Uploader::upload_task(std::unique_ptr<OutputType> task) {
|
|||
std::vector<std::string> *sim_error
|
||||
) {
|
||||
txn->exec_params0(
|
||||
"UPDATE sim_outputs SET sim_log = $1, error_log = $2 WHERE id = $3 AND part_status != 'halted';",
|
||||
"UPDATE sim_outputs SET sim_log = $1, error_log = $2, part_status = 'finished' WHERE id = $3 AND part_status != 'halted';",
|
||||
*sim_log,
|
||||
*sim_error,
|
||||
*target
|
||||
|
|
|
|||
Loading…
Reference in a new issue