-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
DB: clean up tables #12732
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
base: main
Are you sure you want to change the base?
DB: clean up tables #12732
Changes from all commits
8e057a1
f53a526
4cc552a
c697d94
b874996
61d26a2
8cc3a03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||
| from django_dynamic_fixture import get | ||||||||
|
|
||||||||
| from readthedocs.builds.models import Version | ||||||||
| from readthedocs.core.utils.db import delete_in_batches | ||||||||
| from readthedocs.core.utils.db import delete_in_batches, raw_delete_in_batches | ||||||||
| from readthedocs.projects.models import Project | ||||||||
|
|
||||||||
|
|
||||||||
|
|
@@ -127,3 +127,181 @@ def test_versions_deletion_in_batches(self): | |||||||
|
|
||||||||
| # The project should still exist | ||||||||
| assert Project.objects.filter(slug="version-test").count() == 1 | ||||||||
|
|
||||||||
| def test_delete_with_limit_smaller_than_total(self): | ||||||||
| """Test deleting with a limit smaller than total queryset count.""" | ||||||||
| # Create 20 projects | ||||||||
| projects = [get(Project, slug=f"limit-project-{i}") for i in range(20)] | ||||||||
|
||||||||
| projects = [get(Project, slug=f"limit-project-{i}") for i in range(20)] | |
| for i in range(20): | |
| get(Project, slug=f"limit-project-{i}") |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable projects is not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot, YOU wrote these tests >:x
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable projects is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable projects is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
| versions = [get(Version, project=project, slug=f"raw-limit-{i}") for i in range(20)] | |
| for i in range(20): | |
| get(Version, project=project, slug=f"raw-limit-{i}") |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
| versions = [get(Version, project=project, slug=f"raw-eq-lim-{i}") for i in range(10)] | |
| for i in range(10): | |
| get(Version, project=project, slug=f"raw-eq-lim-{i}") |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable versions is not used.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -699,8 +699,15 @@ def BUILD_MEMORY_LIMIT(self): | |||||
| }, | ||||||
| "every-day-delete-old-buildata-models": { | ||||||
| "task": "readthedocs.telemetry.tasks.delete_old_build_data", | ||||||
| "schedule": crontab(minute=0, hour=2), | ||||||
| # NOTE: we are running this task every hour for now, | ||||||
| # since we have lots of objects to delete, and we are limiting | ||||||
| # the number of deletions per task run. | ||||||
| # TODO: go back to once a day (unlimited) after we delete the backlog of objects. | ||||||
| # It should take around ~1 week to delete all the old objects on community, | ||||||
| # commercial doesn't have this problem. | ||||||
| "schedule": crontab(minute=0, hour="*"), | ||||||
| "options": {"queue": "web"}, | ||||||
| "kwargs": {"limit": 10_000}, | ||||||
| }, | ||||||
| "every-day-delete-old-buildconfig-models": { | ||||||
| "task": "readthedocs.builds.tasks.remove_orphan_build_config", | ||||||
|
|
@@ -754,6 +761,23 @@ def BUILD_MEMORY_LIMIT(self): | |||||
| "schedule": crontab(minute=0, hour=4), | ||||||
| "options": {"queue": "web"}, | ||||||
| }, | ||||||
| # TODO: delete this task when all imported files pending deletion are done. | ||||||
| # It shuold take around 36 days to delete all the old imported files on community, | ||||||
|
||||||
| # It shuold take around 36 days to delete all the old imported files on community, | |
| # It should take around 36 days to delete all the old imported files on community, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that we are not inserting new ImportedFiles that don't meet these conditions, right?