Skip to content

DMP-4312: Dets Clean up automated Task#3216

Open
Ben-Edwards-cgi wants to merge 8 commits intomasterfrom
DMP-4312-dets-clean-up
Open

DMP-4312: Dets Clean up automated Task#3216
Ben-Edwards-cgi wants to merge 8 commits intomasterfrom
DMP-4312-dets-clean-up

Conversation

@Ben-Edwards-cgi
Copy link
Copy Markdown
Contributor

JIRA link (if applicable)

https://tools.hmcts.net/jira/browse/DMP-4312

Change description

Created the DETs Clean Up Job

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[X] No

@Ben-Edwards-cgi Ben-Edwards-cgi requested a review from a team as a code owner February 28, 2026 01:29
@Ben-Edwards-cgi Ben-Edwards-cgi requested review from cakeben, karen-hedges and npv0 and removed request for a team February 28, 2026 01:29
# Conflicts:
#	src/integrationTest/java/uk/gov/hmcts/darts/testutils/stubs/DartsDatabaseStub.java
#	src/main/java/uk/gov/hmcts/darts/task/api/AutomatedTaskName.java
}

List<List<CleanUpDetsDataProcessorImpl.CleanUpDetsProcedureResponse>> batchesToDeleteBlobStoreRecordFor =
ListUtils.partition(eodIdsToCleanUp, config.getChunkSize() / config.getThreads());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calculation "outconfig.getChunkSize() / config.getThreads()" should not be passed as a parameter to ensure there are no issues with the value returned

RAISE NOTICE '% Duplicate count = %', c_msg_prefix, v_dup_count;

IF v_dup_count > 0 THEN
RAISE EXCEPTION 'Validation failed: Duplicate records [%] found.', v_dup_count;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will stop the whole process, should this stop the whole process or skip the duplicates?

log.info("Processing clean up of DETS data with chunk size: {}", chunkSize);

List<CleanUpDetsDataProcessorImpl.CleanUpDetsProcedureResponse> eodIdsToCleanUp =
cleanUpDetsDataBatchProcessor.callDetsCleanUpStoredProcedure(chunkSize, minimumStoredAge);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the callDetsCleanUpStoredProcedure throws an exception say because there are duplicate eods, then the whole job finishes. Should there be a try catch inside the while loop so the next chunk can be processed?


for (CleanUpDetsProcedureResponse response : eodsCleanedUp) {
try {
log.debug("Processing clean up response for EOD ID: {}, Location: {}", response.getOsrUuid(), response.getDetsLocation());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the functionality for feature flag logging, can you please change these debug messages to be feature flag controlled so we can turn them on and off when required. I will find an example of how this is currently done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrations need to be updated as we have had various other flyway migration merged

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrations need to be updated as we have had various other flyway migration merged

@@ -0,0 +1,10 @@
INSERT INTO darts.automated_task (aut_id, task_name, task_description, cron_expression, cron_editable, batch_size,
created_ts, created_by, last_modified_ts, last_modified_by, task_enabled)
VALUES (36, 'CleanUpDetsData', 'Cleans up Dets files that have successfully been stored in ARM', '0 24 0-6,19-23 ? * *', true, 100_000,
Copy link
Copy Markdown
Contributor

@karen-hedges karen-hedges Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not use a fixed value 36 for id but should use nextval('aut_seq') as we have added more automated tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants