Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Implement soft deletion on remove_job, to save DjangoJobExecution #113

Open
andrewkoltsov opened this issue Sep 15, 2020 · 5 comments

Comments

@andrewkoltsov
Copy link

Implement soft deletion on remove_job, to save DjangoJobExecution

Expected behavior
After execution "date" job result of this execution stays in DjangoJobExecution table.

@jcass77
Copy link
Owner

jcass77 commented Sep 15, 2020

We could perhaps introduce a DjangoJob.is_removed BooleanField that is set when a job is removed by the scheduler via remove_job. This will also distinguish removed jobs from paused jobs (that just have their next_run_time set to None).

Another aspect to consider is implementing a custom model manager that provides something like an available_jobs convenience method for selecting and excluding jobs that have is_removed=True.

@CharleeSF
Copy link

I think this would also solve my issue that I get a FOREIGN KEY error when django-apscheduler tries to make a DjangoJobExecution object for the first time even though my job has already been removed by apscheduler..

@jcass77
Copy link
Owner

jcass77 commented Oct 12, 2020

I think this would also solve my issue that I get a FOREIGN KEY error when django-apscheduler tries to make a DjangoJobExecution object for the first time even though my job has already been removed by apscheduler..

That should already be fixed as part of #116 and #121. Maybe try checking out the master branch to see if that works for you.

@jcass77
Copy link
Owner

jcass77 commented Jun 18, 2021

One issue with implementing a 'soft delete' feature like this is that, if a job is created that has the same name but vastly different semantic meaning and functionality than a previously deleted job, then linking the old DjangoJobExecution records to the new job might not make sense.

From a user perspective it will seem like this brand new job has in fact been run many times in the past, even though it was just created.

Enforcing unique and non-repeating job names might go some way towards solving the above, but placing the burden of having to continuously come up with creative job names on the user is probably not ideal.

Alternatively, changing the Django models so that DjangoJob uses a sequential number as its ID / primary key might solve the above, but then we have the inverse problem of old DjangoJobExecutions not being linked to semantically the same job when it is re-created again.

Bottom line: how do we know which historical DjangoJobExecutions to link to which DjangoJobs if the user is allowed to re-use job names?

@lvelvee
Copy link

lvelvee commented Oct 16, 2021

Perhaps adding a version field of DjangoJob would be the ideal option. We can determine the version number of a job function by hashing its source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants