there is a built-in job consumer to cleanup historic job data from the 
repository, this should include cancelled jobs.
it's not active by default.

you can use the job api to run this job - example:

String JOB_HISTORY_CLEANUP_TOPIC = 
"org/apache/sling/event/impl/jobs/tasks/HistoryCleanUpTask";

Map<String, Object> jobProperties = new HashMap<String, Object>();
jobProperties.put("age", maxAgeMinutes);
jobManager.addJob(JOB_HISTORY_CLEANUP_TOPIC, jobProperties);


you can runs this e.g. once a day. depending on maxAgeMinutes all job data 
older that this timespan is cleaned up.

empty "folder structures" for years/month/day etc. should get cleaned up 
automatically from time to time.

stefan


>-----Original Message-----
>From: Roll, Kevin [mailto:[email protected]]
>Sent: Tuesday, December 15, 2015 6:27 PM
>To: [email protected]
>Subject: Old jobs in repository
>
>Our application depends on a lot of lightweight jobs that run quickly.
>During field trials we have encountered several instances where the backing
>database for Sling (MS SQL Server) filled up to its maximum capacity of
>4Gb. I have one of these machines in front of me and I've discovered that
>the repository is clogged up with old jobs under the /var/eventing/jobs
>node. The number of jobs is practically uncountable but is potentially in
>the millions given the number of rows in the DEFAULT_BUNDLE table. The
>majority of jobs are under the 'cancelled' node but there are also some
>under the 'unassigned' node. This raises many questions:
>
>* Why are CANCELLED jobs persisted in the repository? Shouldn't they just
>go away?
>* Why would unassigned jobs from many days ago be sitting there? Could
>anything block the job queue from processing them?
>* The jobs are stored under a node structure that uses the
>year/month/day/hour/etc. Does this ever get cleaned up? This node structure
>would continue to grow indefinitely, consuming more space.
>* Is there anything I can do to clean up all these old jobs without
>destroying the rest of my repository?
>
>I should also mention that despite the presence of all these nodes, the
>Sling Jobs status page shows zero for all counters.
>
>Thanks as always, everyone!

Reply via email to