From 31e6900cfb05d573b999d1ea3c54fe6b725138fe Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Wed, 17 Jan 2024 17:27:51 -0500 Subject: [PATCH] fix part status not set to finished, added debug prints --- src/actsim_agent/uploader.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/actsim_agent/uploader.cpp b/src/actsim_agent/uploader.cpp index b5f384f..8f96c54 100644 --- a/src/actsim_agent/uploader.cpp +++ b/src/actsim_agent/uploader.cpp @@ -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 task) { @@ -112,7 +127,7 @@ bool Uploader::upload_task(std::unique_ptr task) { std::vector *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