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

Remove foreign key contraint in table job_warnings on 'fk_jobs_id' #4174

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

svkrieger
Copy link
Contributor

  • A short explanation of the proposed change:

Deletion of foreign key constraint in job_warnings table on fk_jobs_id. This also deletes the column fk_jobs_id.
This will drastically increase the speed of the cleanup job of the pollable jobs table.

  • An explanation of the use cases your change solves

The job_warnings table was created in a wrong way. There are two columns 'job_id' and 'fk_jobs_id'. There is a foreign key constraint on 'fk_jobs_id', which references jobs(id). CC coding never inserts data into 'fk_jobs_id', but only into 'job_id'. So the foreign key constraint is not needed but causes way slower cleanup of pollable jobs, which can even run into DB statement timeouts and cause an ever growing table. CC already takes care of deleting job_warnings when jobs are deleted.

  • Links to any other associated PRs

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

The job_warnings table was created in a wrong way. There are two columns 'job_id' and 'fk_jobs_id'.
There is a foreign key constraint on 'fk_jobs_id', which references jobs(id).
CC coding never inserts data into 'fk_jobs_id', but only into 'job_id'.
So the foreign key constraint is not needed and causes way slower cleanup of pollable jobs,
which can even run into DB statement timeouts and cause an ever growing table.
@svkrieger svkrieger force-pushed the remove-foreign-key-contraint-from-job-warnings branch from 2cf1a79 to ec7b7f9 Compare January 17, 2025 10:02
@svkrieger svkrieger merged commit 8e9bc84 into main Jan 17, 2025
14 checks passed
@svkrieger svkrieger deleted the remove-foreign-key-contraint-from-job-warnings branch January 17, 2025 15:35
@philippthun
Copy link
Member

CC already takes care of deleting job_warnings when jobs are deleted.

Unfortunately this is only partially true. See #4175.

ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Jan 19, 2025
Changes in cloud_controller_ng:

- Remove foreign key contraint in table job_warnings on 'fk_jobs_id'
    PR: cloudfoundry/cloud_controller_ng#4174
    Author: Sven Krieger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants