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

Make job deletion configurable #104

Closed
saurabhnanda opened this issue Oct 9, 2023 · 5 comments · Fixed by #106
Closed

Make job deletion configurable #104

saurabhnanda opened this issue Oct 9, 2023 · 5 comments · Fixed by #106
Labels
enhancement New feature or request

Comments

@saurabhnanda
Copy link
Owner

saurabhnanda commented Oct 9, 2023

Currently there are only two options here:

  • cfgDeleteSuccessfulJobs: True or False

I propose something like the following:

data Config = Config
  { -- | This function will be evaluated every time a job is attempted (at the __end__ of the attempt)
   cfgImmediateJobDeletion :: Job -> IO Bool 

   -- | Another polling thread will be setup to run every 'cfgPollingInterval' seconds to execute this query
  , cfgDelayedJobDeletionSql :: PGS.Query
  , ...
  } 

defaultImmediateJobDeletion :: Job -> IO Bool
defaultImmedateJobDeletion Job{jobStatus} = 
  pure $ jobStatus == Success

defaultDeleayedJobDeletionSql :: PGS.Query
defaultDeleayedJobDeletionSql = 
  "DELETE FROM jobs WHERE status in ('success', 'failed') AND run_at < current_timestamp - '7 days'::interval"

Use cases

  • cleanup of failed jobs after enough time has passed (this is the same as Implement reaper for failed/stale jobs #22)
  • delay a job's deletion for cases where an ephemeral job result
  • make job deletion logic highly configurable (useful for advanced use-cases like "workflows" -- coming up in a future PR)
@saurabhnanda saurabhnanda added the enhancement New feature or request label Oct 9, 2023
@saurabhnanda
Copy link
Owner Author

Folks, if anyone has a strong objection to the above proposal, please let me know.

@ivb-supercede @tfausak @jappeace @tchoutri

Please tag any other active users of odd-jobs as well.

@tchoutri
Copy link
Contributor

tchoutri commented Oct 9, 2023

LGTM 👍

@jappeace
Copy link
Collaborator

jappeace commented Oct 9, 2023

would be nice this could be changed without breaking existing code

@saurabhnanda
Copy link
Owner Author

@jappeace if the fields of Config are changed but the type-signature of OddJobs.ConfigBuilder.mkConfig is maintained, even , would that work for you?

cc: @tfausak

@jappeace
Copy link
Collaborator

I think that's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants