@Override
    public void delete(final Instant deleteThreshold) {
        final TaskContext taskContext = taskContextFactory.current();

        // Logically delete tasks that are associated with filters that have been logically deleted for longer than the
        // threshold.
        final AtomicInteger totalCount = new AtomicInteger();
        taskContext.info(() -> "Logically deleting processor tasks for deleted processor filters");
        runWithCountAndTimeLogging(() -> processorTaskDao.logicalDeleteForDeletedProcessorFilters(deleteThreshold),
                totalCount,
                "Logically deleted {} processor tasks for deleted processor filters");

        // Logically delete COMPLETE processor filters with no outstanding tasks where the tracker last poll is older
        // than the threshold. Note that COMPLETE just means that we have finished producing tasks on the DB, but we
        // can't delete the filter until all associated tasks have been processed otherwise they will never be picked
        // up.
        taskContext.info(() -> "Logically deleting old processor filters with a state of COMPLETED and no tasks");
        runWithCountAndTimeLogging(() -> processorFilterDao.logicallyDeleteOldProcessorFilters(deleteThreshold),
                totalCount,
                "Logically deleted {} old processor filters with a state of " + "COMPLETED and no tasks");

        // Physically delete tasks that are logically deleted or complete for longer than the threshold.
        taskContext.info(() -> "Physically deleting old processor tasks with a state of (COMPLETED|DELETED)");
        runWithCountAndTimeLogging(() -> processorTaskDao.physicallyDeleteOldTasks(deleteThreshold),
                totalCount,
                "Physically deleted {} old processor tasks with a state of " + "(COMPLETED|DELETED)");

        // Physically delete old filters.
        taskContext.info(() -> "Physically deleting old processor filters with state of DELETED");
        runWithCountAndTimeLogging(() -> deletingOldProcessorFilters(deleteThreshold),
                totalCount,
                "Physically deleted {} old processor filters with state of DELETED");

        // Physically delete old processors.
        taskContext.info(() -> "Physically deleting old processors with state of DELETED");
        runWithCountAndTimeLogging(() -> processorDao.physicalDeleteOldProcessors(deleteThreshold),
                totalCount,
                "Physically deleted {} old processors with state of DELETED");

        if (totalCount.get() == 0) {
            LOGGER.info("{} - No records logically or physically deleted", TASK_NAME);
        }
    }
Synchronised as we don't want to run more than once concurrently.
stroom-processor/stroom-processor-impl-db/src/main/java/stroom/processor/impl/db/ProcessorTaskDeleteExecutorImpl.java