Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz JDBC Job Store - Maintenance/Cleanup

I am currently in the processes of setting up Quartz in a load balanced environment using the JDBC job store and I am wondering how everyone manages the quartz job store DB.

For me Quartz (2.2.0) will be deployed as a part of a versioned application with multiple versions potentially existing on the one server at the one time. I am using the notation XXScheduler_v1 to ensure multiple schedulers play nice together. My code is working fine, with the quartz tables being populated with the triggers/jobs/etc as appropriate.

One thing I have noticed though is that there seems to be no database cleanup that occurs when the application is undeployed. What I mean is that the Job/Scheduler data seems to stay in the quartz database even though there is no longer a scheduler active.

This is less than ideal and I can imagine with my model the database would get larger than it needed to be with time. Am I missing how to hook-up some clean-up processes? Or does quartz expect us to do the db cleanup manually?

Cheers!

like image 881
vica Avatar asked Mar 24 '23 03:03

vica


1 Answers

I got this issue once, and here is what I did to rectify the issue. This will work for sure but in case it does not then we will have backup of table so you don't have anything to loose while trying this.

  1. Take sql dump of following tables using method mentioned at : Taking backup of single table
    a) QRTZ_CRON_TRIGGERS
    b) QRTZ_SIMPLE_TRIGGERS
    c) QRTZ_TRIGGERS
    d) QRTZ_JOB_DETAILS
  1. Delete data from above tables in sequence as

    delete from QRTZ_CRON_TRIGGERS;
    delete from QRTZ_SIMPLE_TRIGGERS;
    delete from QRTZ_TRIGGERS;
    delete from QRTZ_JOB_DETAILS;
    
  2. Restart your app which will then freshly insert all deleted tasks and related entries in above tables (Provided your app has its logic right).

This is more like starting your app with all the tasks being scheduled for the first time. So you must keep in mind that tasks will behave as if these are freshly inserted.

NOTE: If this does not work then apply the backup you took for tables and try to debug more closely. As of now, I have not seen this method fail.

like image 117
dhiraj singh Avatar answered Mar 25 '23 18:03

dhiraj singh