Fix not deleting the assignment-records, for every workerReport, after processing it.

This commit is contained in:
Lampros Smyrnaios 2023-08-30 16:22:58 +03:00
parent aa3f32f3da
commit c32dfa882e
1 changed files with 11 additions and 8 deletions

View File

@ -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;