-
Notifications
You must be signed in to change notification settings - Fork 23
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
add scripts to backfill undelegated fields in db #833
add scripts to backfill undelegated fields in db #833
Conversation
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.
$ make distcheck
"/usr/local/bin/perl" "-Iinc" "-MExtUtils::Manifest=fullcheck" -e fullcheck
Not in MANIFEST: share/patch_mysql_db_zonemaster_backend_ver_7.0.0.pl
Not in MANIFEST: share/patch_sqlite_db_zonemaster_backend_ver_7.0.0.pl
I have tested SQLite where some delegated were reported as undelegated and vice versa. After running the script all were in the correct category. In the instructions there is an extra step for FreeBSD ( Replace
with
I have tested this with SQLite, but it should work the same way in the other scripts. |
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.
The following files must also be update: README.md and docs/upgrade_db_zonemaster_backend_ver_7.0.0.md
For this issue I suggest a small change in configuration loading, see #835 |
Those files have been updated. |
|
README.md
Outdated
@@ -40,7 +40,7 @@ Older than 1.0.3 | [Upgrade to 1.0.3] | | |||
At least 1.0.3 but older than 1.1.0 | [Upgrade to 1.1.0] | | |||
At least 1.1.0 but older than 5.0.0 | [Upgrade to 5.0.0] | | |||
At least 5.0.0 but older than 5.0.2 | [Upgrade to 5.0.2] | For MySQL/MariaDB only | |||
At least 5.0.2 but older than 7.0.0 | [Upgrade to 7.0.0] | For PostgreSQL only | |||
At least 5.0.2 but older than 7.0.0 | [Upgrade to 7.0.0] | For all database types |
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 suggest that the comment is empty when all database engines are affected.
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.
done
If #835 is accepted, then that should be merged first, and then the special instructions for FreeBSD in the upgrade instructions can be removed. |
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.
Looks good. A small comment though and I commented #835 as well.
eval { | ||
$dbh->do( 'ALTER TABLE test_results ADD COLUMN undelegated integer NOT NULL DEFAULT 0' ); | ||
}; | ||
print "Error while changing DB schema: " . $@; |
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.
Shouldn't this be printed only if there are errors?
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.
Yes indeed, fixed.
Merge #835, rebase this and remove the special setting for FreeBSD. |
This is now done. |
print "Error while changing DB schema: " . $@; | ||
} | ||
|
||
$dbh->do( qq[ |
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.
Could this be done using the much simpler for-loop from the MySQL and SQLite implementations?
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.
It could but it has a impact on the performance. Processing 13K rows (about 1% of the zonemaster.net database) with the sql statement takes around 1 second and doing it with the while loop takes 17 seconds.
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.
That's an impressive difference. But this is a one-time task.
And the SQL statement is quite complex. What are the chances that a bug has snuck into it?
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.
Fair enough, I can can change it to the other implementation.
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.
@blacksponge, have you addressed the comment from @mattias-p?
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.
It has now been addressed.
When @blacksponge and @mattias-p agree on |
Purpose
Update the old 'undelegated' values in the database.
Context
Fixes #829
Changes
Add patch scripts.
How to test this PR
Postgres
Check the value of delegated vs undelegated tests (all test are delegated, so the second query should return nothing except if you have the patch for undelegated tests in which case there can be a few).
Apply update script
perl zonemaster-backend/share/patch_postgresql_db_zonemaster_backend_ver_7.0.0.pl
(ignore error if the table has already been changed, "if not exists" is not compatible with PG 9.3)Repeat the first step to verify that all tests has been classified correctly.
MySQL
Check the value of delegated vs undelegated tests (all test are delegated, so the second query should return nothing except if you have the patch for undelegated tests in which case there can be a few).
Apply update script
perl zonemaster-backend/share/patch_mysql_db_zonemaster_backend_ver_7.0.0.pl
Repeat the first step to verify that all tests has been classified correctly.