[PDB-tech] peeringdb sync - sometimes gets errors.
All, Occasionally I get errors from doing a sync command.
django.core.exceptions.ValidationError: {'name': [u'Organization with this Name already exists.']}
I've gone back-n-forth on trying to fix this; however I realized I should share this sql script that I run prior to "sync" in order to fix this. Once you run "sync" you have a clean copy of PeeringDB. This can be found at https://github.com/peeringdb/peeringdb-py/pull/7 Enjoy, Martin ----------- $ cat drop-tables-peeringdb.sql DROP TABLE IF EXISTS peeringdb_facility; DROP TABLE IF EXISTS peeringdb_ix; DROP TABLE IF EXISTS peeringdb_ix_facility; DROP TABLE IF EXISTS peeringdb_ixlan; DROP TABLE IF EXISTS peeringdb_ixlan_prefix; DROP TABLE IF EXISTS peeringdb_network; DROP TABLE IF EXISTS peeringdb_network_contact; DROP TABLE IF EXISTS peeringdb_network_facility; DROP TABLE IF EXISTS peeringdb_network_ixlan; DROP TABLE IF EXISTS peeringdb_organization; DROP TABLE IF EXISTS auth_group; DROP TABLE IF EXISTS auth_group_permissions; DROP TABLE IF EXISTS auth_permission; DROP TABLE IF EXISTS auth_user; DROP TABLE IF EXISTS auth_user_groups; DROP TABLE IF EXISTS auth_user_user_permissions; DROP TABLE IF EXISTS django_admin_log; DROP TABLE IF EXISTS django_content_type; DROP TABLE IF EXISTS django_migrations; DROP TABLE IF EXISTS django_session; $
While it's good to clear out the old table while loading it in, you might want to consider something along the lines of: drop table if exists peeringdb_facility_temp ; create table peeringdb_facility_temp like peeringdb_facility ; insert into peeringdb_facility_temp ... ; rename table peeringdb_facility to peeringdb_facility_old, peeringdb_facility_temp to peeringdb_facility ; drop table peeringdb_facility_old ; (repeat for each table - ideally in a loop with dynamically specified table names instead of hardcoded ones... ) This way you don't end up with a gap where the table doesn't exist while you're re-creating it. -Steve
On Apr 13, 2016, at 5:29 PM, Martin J. Levy <mahtin@mahtin.com> wrote:
All,
Occasionally I get errors from doing a sync command.
django.core.exceptions.ValidationError: {'name': [u'Organization with this Name already exists.']}
I've gone back-n-forth on trying to fix this; however I realized I should share this sql script that I run prior to "sync" in order to fix this. Once you run "sync" you have a clean copy of PeeringDB.
This can be found at https://github.com/peeringdb/peeringdb-py/pull/7
Enjoy,
Martin
----------- $ cat drop-tables-peeringdb.sql DROP TABLE IF EXISTS peeringdb_facility; DROP TABLE IF EXISTS peeringdb_ix; DROP TABLE IF EXISTS peeringdb_ix_facility; DROP TABLE IF EXISTS peeringdb_ixlan; DROP TABLE IF EXISTS peeringdb_ixlan_prefix; DROP TABLE IF EXISTS peeringdb_network; DROP TABLE IF EXISTS peeringdb_network_contact; DROP TABLE IF EXISTS peeringdb_network_facility; DROP TABLE IF EXISTS peeringdb_network_ixlan; DROP TABLE IF EXISTS peeringdb_organization; DROP TABLE IF EXISTS auth_group; DROP TABLE IF EXISTS auth_group_permissions; DROP TABLE IF EXISTS auth_permission; DROP TABLE IF EXISTS auth_user; DROP TABLE IF EXISTS auth_user_groups; DROP TABLE IF EXISTS auth_user_user_permissions; DROP TABLE IF EXISTS django_admin_log; DROP TABLE IF EXISTS django_content_type; DROP TABLE IF EXISTS django_migrations; DROP TABLE IF EXISTS django_session; $ _______________________________________________ Pdb-tech mailing list Pdb-tech@lists.peeringdb.com http://lists.peeringdb.com/cgi-bin/mailman/listinfo/pdb-tech
And if a dedicated sqlite file, you can just remove the sqlite3 file to start from scratch. I normally cron run "peeringdb sync" hourly with "> /dev/null 2>&1" which masks these errors, so once per day I run without a filter. Ex.: # Hourly update to peeringdb file 00 1-23 * * * sleep $[RANDOM\%300] ; /home/seaix/src/wiki_ip_converter/pdbvenv/bin/peeringdb sync > /dev/null 2>&1 # Do a daily run without error filtering, so we can learn about any errors. 00 00 * * * sleep $[RANDOM\%300] ; /home/seaix/src/wiki_ip_converter/pdbvenv/bin/peeringdb sync Martin, I opened an issue and added your error to it: https://github.com/peeringdb/peeringdb-py/issues/6 Thanks, Chris On Wed, 13 Apr 2016, Martin J. Levy wrote:
All, Occasionally I get errors from doing a sync command.
django.core.exceptions.ValidationError: {'name': [u'Organization with this Name already exists.']} I've gone back-n-forth on trying to fix this; however I realized I should share this sql script that I run prior to "sync" in order to fix this. Once you run "sync" you have a clean copy of PeeringDB.
This can be found at https://github.com/peeringdb/peeringdb-py/pull/7
Enjoy,
Martin
----------- $ cat drop-tables-peeringdb.sql DROP TABLE IF EXISTS peeringdb_facility; DROP TABLE IF EXISTS peeringdb_ix; DROP TABLE IF EXISTS peeringdb_ix_facility; DROP TABLE IF EXISTS peeringdb_ixlan; DROP TABLE IF EXISTS peeringdb_ixlan_prefix; DROP TABLE IF EXISTS peeringdb_network; DROP TABLE IF EXISTS peeringdb_network_contact; DROP TABLE IF EXISTS peeringdb_network_facility; DROP TABLE IF EXISTS peeringdb_network_ixlan; DROP TABLE IF EXISTS peeringdb_organization; DROP TABLE IF EXISTS auth_group; DROP TABLE IF EXISTS auth_group_permissions; DROP TABLE IF EXISTS auth_permission; DROP TABLE IF EXISTS auth_user; DROP TABLE IF EXISTS auth_user_groups; DROP TABLE IF EXISTS auth_user_user_permissions; DROP TABLE IF EXISTS django_admin_log; DROP TABLE IF EXISTS django_content_type; DROP TABLE IF EXISTS django_migrations; DROP TABLE IF EXISTS django_session; $
This should function as expected with the 2.0.8 release - please test and get back to us. I'm glad you guys found and posted work arounds, but the goal is to never have to drop and do a fresh sync :) Cheers! * Chris Caputo <ccaputo@alt.net> [160413 21:40 +0000]:
And if a dedicated sqlite file, you can just remove the sqlite3 file to start from scratch.
I normally cron run "peeringdb sync" hourly with "> /dev/null 2>&1" which masks these errors, so once per day I run without a filter. Ex.:
# Hourly update to peeringdb file 00 1-23 * * * sleep $[RANDOM\%300] ; /home/seaix/src/wiki_ip_converter/pdbvenv/bin/peeringdb sync > /dev/null 2>&1 # Do a daily run without error filtering, so we can learn about any errors. 00 00 * * * sleep $[RANDOM\%300] ; /home/seaix/src/wiki_ip_converter/pdbvenv/bin/peeringdb sync
Martin, I opened an issue and added your error to it:
https://github.com/peeringdb/peeringdb-py/issues/6
Thanks, Chris
On Wed, 13 Apr 2016, Martin J. Levy wrote:
All, Occasionally I get errors from doing a sync command.
django.core.exceptions.ValidationError: {'name': [u'Organization with this Name already exists.']} I've gone back-n-forth on trying to fix this; however I realized I should share this sql script that I run prior to "sync" in order to fix this. Once you run "sync" you have a clean copy of PeeringDB.
This can be found at https://github.com/peeringdb/peeringdb-py/pull/7
Enjoy,
Martin
----------- $ cat drop-tables-peeringdb.sql DROP TABLE IF EXISTS peeringdb_facility; DROP TABLE IF EXISTS peeringdb_ix; DROP TABLE IF EXISTS peeringdb_ix_facility; DROP TABLE IF EXISTS peeringdb_ixlan; DROP TABLE IF EXISTS peeringdb_ixlan_prefix; DROP TABLE IF EXISTS peeringdb_network; DROP TABLE IF EXISTS peeringdb_network_contact; DROP TABLE IF EXISTS peeringdb_network_facility; DROP TABLE IF EXISTS peeringdb_network_ixlan; DROP TABLE IF EXISTS peeringdb_organization; DROP TABLE IF EXISTS auth_group; DROP TABLE IF EXISTS auth_group_permissions; DROP TABLE IF EXISTS auth_permission; DROP TABLE IF EXISTS auth_user; DROP TABLE IF EXISTS auth_user_groups; DROP TABLE IF EXISTS auth_user_user_permissions; DROP TABLE IF EXISTS django_admin_log; DROP TABLE IF EXISTS django_content_type; DROP TABLE IF EXISTS django_migrations; DROP TABLE IF EXISTS django_session; $
participants (4)
-
Chris Caputo -
Martin J. Levy -
Matt Griswold -
Stephen McManus