New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 765795 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Sep 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 762070



Sign in to add a comment

db_cleanup fails with IntegrityError

Project Member Reported by pho...@chromium.org, Sep 15 2017

Issue description

chromeos-test@chromeos-server25:/usr/local/autotest$ /usr/local/autotest/contrib/db_cleanup.py `date --date='3 month ago' +\\%Y-\\%m-\\%d` --load_ratio 0.1 --step 100 2>&1 | tee -a /usr/local/autotest/logs/db_cleanup.log
2017-09-14 16:43:38,563 - INFO - Calling: ['/usr/local/autotest/contrib/db_cleanup.py', '2017-06-14', '--load_ratio', '0.1', '--step', '100']
2017-09-14 16:43:38,565 - INFO - Cleaning up all afe_job data prior to 2017-06-12.
afe_aborted_host_queue_entries           [===================>] (    12156/    12156)
afe_special_tasks                        [===================>] (     1820/     1820)
afe_host_queue_entries                   [===================>] (   168786/   168786)
afe_job_keyvals                          [===================>] (   846148/   846148)
afe_jobs_dependency_labels               [===================>] ( 13903037/ 13903037)
afe_jobs                                 [                    ] (      800/ 29998696)
Traceback (most recent call last):
  File "/usr/local/autotest/contrib/db_cleanup.py", line 392, in <module>
    main()
  File "/usr/local/autotest/contrib/db_cleanup.py", line 388, in main
    _delete_all_data_before_date(args.date)
  File "/usr/local/autotest/contrib/db_cleanup.py", line 290, in _delete_all_data_before_date
    afe_date, time_column='created_on')
  File "/usr/local/autotest/contrib/db_cleanup.py", line 215, in _delete_table_data_before_date
    cursor.execute(sql, [])
  File "/usr/local/autotest/site-packages/django/db/backends/mysql/base.py", line 122, in execute
    six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
  File "/usr/local/autotest/site-packages/django/db/backends/mysql/base.py", line 120, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/autotest/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/autotest/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`chromeos_autotest_db`.`afe_recurring_run`, CONSTRAINT `recurring_run_job_id_fk` FOREIGN KEY (`job_id`) REFERENCES `afe_jobs` (`id`) ON DELETE NO ACTION)')



 

Comment 1 by pho...@chromium.org, Sep 27 2017

Status: Verified (was: Started)
Fixed by removing the row from afe_recurring_run, which appears to be dead.

Sign in to add a comment