public int logicallyDeleteOldFilters(final Instant deleteThreshold, final DSLContext context) {
        var query = context
                .update(PROCESSOR_FILTER)
                .set(PROCESSOR_FILTER.DELETED, true)
                .set(PROCESSOR_FILTER.VERSION, PROCESSOR_FILTER.VERSION.plus(1))
                .set(PROCESSOR_FILTER.UPDATE_TIME_MS, Instant.now().toEpochMilli())
                .where(PROCESSOR_FILTER.DELETED.eq(false))
                .and(DSL.exists(
                        DSL.selectZero()
                                .from(PROCESSOR_FILTER_TRACKER)
                                .where(PROCESSOR_FILTER_TRACKER.ID.eq(PROCESSOR_FILTER.FK_PROCESSOR_FILTER_TRACKER_ID))
                                .and(PROCESSOR_FILTER_TRACKER.STATUS.eq(
                                        ProcessorFilterTrackerStatus.COMPLETE.getPrimitiveValue()))
                                .and(PROCESSOR_FILTER_TRACKER.LAST_POLL_MS.lessThan(deleteThreshold.toEpochMilli()))))
                .and(DSL.notExists(
                        DSL.selectZero()
                                .from(PROCESSOR_TASK)
                                .where(PROCESSOR_TASK.FK_PROCESSOR_FILTER_ID.eq(PROCESSOR_FILTER.ID))));

        LOGGER.trace("logicallyDeleteOldFilters query:\n{}", query);
        final int count = query.execute();

        LOGGER.debug("Logically deleted {} processor filters with a state of COMPLETE with no outstanding tasks and " +
                     "last poll before {}",
                count, deleteThreshold);
        return count;
    }
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.

@param deleteThreshold Only logically delete filters with a last poll time older than the threshold.
@return The number of logically deleted filters.
stroom-processor/stroom-processor-impl-db/src/main/java/stroom/processor/impl/db/ProcessorFilterDaoImpl.java