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

Builds: don't delete them when a version is deleted #7679

Merged
merged 10 commits into from Dec 14, 2020

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Nov 18, 2020

We lose information when a version is deleted.
Setting the version to null allow us to keep the builds around.
But now we need to save more data to be able to reproduce some links.

A data migration is needed to update old builds, but isn't required,
as we fallback to the value from the version.

Close #7674

We lose information when a version is deleted.
Setting the version to null allow us to keep the builds around.
But now we need to save more data to be able to reproduce some links.

A data migration is needed to update old builds, but isn't required,
as we fallback to the value from the version.

Close #7674
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start. A little annoying, but not deleting builds seems worth the trouble 👍

readthedocs/builds/models.py Show resolved Hide resolved
def get_version_type(self):
if self.version:
return self.version.type
return self.version_type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just always use the denormalized values here. I don't think they'll ever change, hopefully.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think is better to use the saved values, since they are from when the build happened, if they change, they aren't part of that build anymore. I'm doing this for now till we fully migrate the data from the old builds. I'm worried that would take some time as we would be iterating over each build D: maybe do the data migration in another PR?

Build = apps.get_model('builds', 'Build')
for build in Build.objects.all():
# When the build is saved, the fields are updated.
build.save()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about this migration... I think is going to take a while, and maybe block the table? We could also do this incrementally, this is by overriding the delete method of the version (or use the pre-signal) and update all of their builds before that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it will block. It's basically just running the Python code -- but we should definitely be using an iterator() here, or finding another clean way of handling this without eating a ton of memory.

Copy link
Member Author

@stsewd stsewd Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated! Also, we can run 0032 and 0033 after the deploy, so we don't need to wait so long before deploying the webs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added that note in the release board

@stsewd stsewd marked this pull request as ready for review November 25, 2020 16:17
@stsewd stsewd requested a review from a team November 25, 2020 16:18
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pretty much looks ready to me. I haven't run it locally, but if it tests well I think we can ship it.

Build = apps.get_model('builds', 'Build')
for build in Build.objects.all():
# When the build is saved, the fields are updated.
build.save()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it will block. It's basically just running the Python code -- but we should definitely be using an iterator() here, or finding another clean way of handling this without eating a ton of memory.

@stsewd stsewd merged commit 05507be into master Dec 14, 2020
3 checks passed
@stsewd stsewd deleted the dont-cascade-delete-builds branch December 14, 2020 20:21
stsewd added a commit that referenced this pull request Dec 16, 2020
With builds/0032 the migration was taking too long.
Migrate old builds before the version is deleted instead.

Ref #7679
stsewd added a commit that referenced this pull request Dec 16, 2020
With builds/0032 the migration was taking too long.
Migrate old builds before the version is deleted instead.

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

Successfully merging this pull request may close these issues.

External versions: keep build log
2 participants