private void checkRetention(final IndexShard shard) {
        try {
            // Delete this shard if it is older than the retention age.
            final LuceneIndexDoc index = indexStore.readDocument(
                    new DocRef(LuceneIndexDoc.TYPE, shard.getIndexUuid()));
            if (index == null) {
                // If there is no associated index then delete the shard.
                indexShardWriterCache.delete(shard.getId());

            } else {
                final Integer retentionDayAge = index.getRetentionDayAge();
                final Long partitionToTime = shard.getPartitionToTime();
                if (retentionDayAge != null
                    && partitionToTime != null
                    && !IndexShardStatus.DELETED.equals(shard.getStatus())) {
                    // See if this index shard is older than the index retention
                    // period.
                    final long retentionTime = ZonedDateTime.now(ZoneOffset.UTC)
                            .minusDays(retentionDayAge)
                            .toInstant()
                            .toEpochMilli();

                    if (partitionToTime < retentionTime) {
                        indexShardWriterCache.delete(shard.getId());
                    }
                }
            }
        } catch (final DocumentNotFoundException e) {
            // If there is no associated index then delete the shard.
            indexShardWriterCache.delete(shard.getId());

        } catch (final RuntimeException e) {
            LOGGER.error(e::getMessage, e);
        }
    }
Delete anything that has been marked to delete
stroom-index/stroom-index-impl/src/main/java/stroom/index/impl/IndexShardManager.java