Skip to content

Commit

Permalink
0003563: The query has timed out. purgeExtractRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Oct 11, 2021
1 parent 1708bb8 commit 749dbdd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,19 @@ public long[] mapRow(Row rs) {

private long purgeExtractRequests() {
Calendar retentionCutoff = Calendar.getInstance();
retentionCutoff.add(Calendar.MINUTE, -parameterService
.getInt(ParameterConstants.PURGE_EXTRACT_REQUESTS_RETENTION_MINUTES));
retentionCutoff.add(Calendar.MINUTE, -parameterService.getInt(ParameterConstants.PURGE_EXTRACT_REQUESTS_RETENTION_MINUTES));
log.info("Purging table reload statuses that are older than {}", retentionCutoff.getTime());
long count = sqlTemplate.update(getSql("deleteTableReloadStatusSql"), retentionCutoff.getTime());
if (count > 0) {
log.info("Purged {} table reload statuses", count);
}
log.info("Purging table reload requests that are older than {}", retentionCutoff.getTime());
count = sqlTemplate.update(getSql("deleteTableReloadRequestSql"), retentionCutoff.getTime());
if (count > 0) {
log.info("Purged {} table reload requests", count);
}
log.info("Purging extract requests that are older than {}", retentionCutoff.getTime());
long count = sqlTemplate.update(getSql("deleteExtractRequestSql"),
ExtractRequest.ExtractStatus.OK.name(), retentionCutoff.getTime());
count = sqlTemplate.update(getSql("deleteExtractRequestSql"), ExtractRequest.ExtractStatus.OK.name(), retentionCutoff.getTime());
if (count > 0) {
log.info("Purged {} extract requests", count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ public PurgeServiceSqlMap(IDatabasePlatform platform, Map<String, String> replac
// @formatter:off

putSql("minDataGapStartId", "select min(start_id) from $(data_gap)");

putSql("deleteExtractRequestSql", "delete from $(extract_request) where status=? and last_update_time < ? and "
+ "0 = (select count(1) from $(outgoing_batch) where status != 'OK' and batch_id between $(extract_request).start_batch_id and $(extract_request).end_batch_id)");

putSql("deleteTableReloadStatusSql", "delete from $(table_reload_status) where completed = 1 and last_update_time < ?");

putSql("deleteTableReloadRequestSql", "delete from $(table_reload_request) where processed = 1 and last_update_time < ? and " +
"(select count(*) from $(table_reload_status) where $(table_reload_status).load_id = $(table_reload_request).load_id) = 0");

putSql("deleteExtractRequestSql", "delete from $(extract_request) where status = ? and last_update_time < ? and " +
"(select count(*) from $(table_reload_status) where $(table_reload_status).load_id = $(extract_request).load_id) = 0");

putSql("deleteRegistrationRequestSql", "delete from $(registration_request) where status in (?,?,?) and last_update_time < ?");

Expand Down

0 comments on commit 749dbdd

Please sign in to comment.