Skip to content

Commit

Permalink
#279 pause 20s if rematching timeout >20s
Browse files Browse the repository at this point in the history
  • Loading branch information
qifeng-bai committed Feb 8, 2024
1 parent a815dab commit 35df2f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ class SpeciesListController {
render(text: "${message(code: 'admin.lists.page.button.rematch.messages', default: 'Rematch complete')}")
}


private parseDataFromCSV(CSVReader csvReader, String separator) {
def rawHeader = csvReader.readNext()
log.debug(rawHeader.toList()?.toString())
Expand Down
19 changes: 11 additions & 8 deletions grails-app/services/au/org/ala/specieslist/HelperService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,10 @@ class HelperService {
} else {
totalRows = SpeciesListItem.count();
//Total rematch - Clean matchedSpecies table
// MatchedSpecies.withTransaction {
// MatchedSpecies.executeUpdate("delete from MatchedSpecies")
// SpeciesListItem.executeUpdate("update SpeciesListItem set matched_species_id = null")
// }
MatchedSpecies.withTransaction {
MatchedSpecies.executeUpdate("delete from MatchedSpecies")
SpeciesListItem.executeUpdate("update SpeciesListItem set matched_species_id = null")
}
}
}
RematchLog.withTransaction {
Expand Down Expand Up @@ -1002,7 +1002,7 @@ class HelperService {
rematchLog.remaining = totalRows - offset
}
RematchLog.withTransaction {
def waitTime = 60 * 1000
def waitTime = 30 * 1000

def timeUsed = TimeCategory.minus(new Date(), start).toMilliseconds()
if (timeUsed < waitTime) {
Expand All @@ -1011,9 +1011,12 @@ class HelperService {
rematchLog.recentProcessTime = new Date()
rematchLog.persist()
} else if (timeUsed >= waitTime ) {
// More than 5 minutes
log.info("Timeout. Rematching is aborted")
throw new Exception("Aborted. ${items.last().id} was rematched!")
// More than 30s
rematchLog.logs = "Pause for ${waitTime} seconds"
rematchLog.currentRecordId = items.last().id
rematchLog.recentProcessTime = new Date()
rematchLog.persist()
sleep(waitTime)
}
}
}// end full iteration
Expand Down

0 comments on commit 35df2f9

Please sign in to comment.