From c32dfa882ef2b05bfb97f28bb2c8f61bb1d0cbad Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Wed, 30 Aug 2023 16:22:58 +0300 Subject: [PATCH] Fix not deleting the assignment-records, for every workerReport, after processing it. --- .../services/UrlsServiceImpl.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java b/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java index 1631841..fa6ea6a 100644 --- a/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java +++ b/src/main/java/eu/openaire/urls_controller/services/UrlsServiceImpl.java @@ -401,10 +401,20 @@ public class UrlsServiceImpl implements UrlsService { } } + // Delete the assignments each time, as they are bound to the "current" assignmentsCounter. Otherwise, they will never be deleted! + DatabaseConnector.databaseLock.lock(); + String deleteErrorMsg = deleteAssignmentsBatch(curReportAssignmentsCounter); + if ( deleteErrorMsg != null ) { + DatabaseConnector.databaseLock.unlock(); + postReportResultToWorker(curWorkerId, curReportAssignmentsCounter, deleteErrorMsg); + return false; + } + DatabaseConnector.databaseLock.unlock(); + // For every "numOfWorkers" assignment-batches that go to workers, we merge the tables, once a workerReport comes in. // After the first few increases of "assignmentsBatchCounter" until all workers get assignment-batches, // there will always be a time when the counter will be just before the "golden-value" and then one workerReport has to be processed here and the counter will be incremented by one and signal the merging-time. - if ( (currentNumOfWorkerReportsProcessed % UrlsController.numOfWorkers.get()) == 0 ) + if ( (currentNumOfWorkerReportsProcessed % UrlsController.numOfWorkers.get()) == 0 ) // The workersNum should not be zero! If a "division by zero" exception is thrown below, then there's a big bug somewhere in the design. if ( ! mergeWorkerRelatedTables(curWorkerId, curReportAssignmentsCounter, hasAttemptParquetFileProblem, hasPayloadParquetFileProblem) ) return false; @@ -487,13 +497,6 @@ public class UrlsServiceImpl implements UrlsService { } } - mergeErrorMsg = deleteAssignmentsBatch(curReportAssignmentsCounter); - if ( mergeErrorMsg != null ) { - DatabaseConnector.databaseLock.unlock(); - postReportResultToWorker(curWorkerId, curReportAssignmentsCounter, mergeErrorMsg); - return false; - } - DatabaseConnector.databaseLock.unlock(); logger.debug("Finished merging the database tables."); return true;