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

Reduce the number of save() operations when a Zone object is saved #198

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

peteeckel
Copy link
Owner

fixes #197

This PR addresses the problem of excessive save() operations for Zone objects on multiple levels.

The main remedy is to introduce a volatile soa_serial_dirty attribute for zones, which can be set by other methods when the serial number of a zone needs to be increased, but not saved. This makes it possible for bulk operations on records to make sure that a zone's SOA Serial number will be updated, but without hitting the database.

This feature is then used throughout the Zone and Record models to determine if and when a Zone object needs to be updated immediately (including the generation of a new version of the SOA record), and when it is OK to defer this operation. This is a surprisingly non-trivial decision.

To support this new functionality and ensure that the serial numbers are created at the right times, the test cases for the Auto SOA Serial feature was extended to cover many edge cases.

* No longer update zones with every record update, e.g. when renaming zones,
  creating PTR zones etc.

* Improve save performance by using update_fields on save()
@peteeckel peteeckel merged commit e3580b6 into main Mar 5, 2024
13 checks passed
@peteeckel peteeckel deleted the fix/reduce-save-operations-for-zones branch March 5, 2024 15:59
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.

Excessive number of save() operations for Zone objects
1 participant