dragonresearch / rpki.net

Dragon Research Labs rpki.net RPKI toolkit
54 stars 26 forks source link

backtrace when deleting roa in hackathon2 #433

Closed sraustein closed 11 years ago

sraustein commented 11 years ago

When an attendee try to remove roa on GUI, an error is comming up, some times. (5 tried, 3 failed) What is happening and what we do to correct?


IntegrityError at /rpki/roa/22/delete

(1451, 'Cannot delete or update a parent row: a foreign key constraint fails (irdbd.irdb_roarequestprefix, CONSTRAINT roa_request_id_refs_id_2efe3213 FOREIGN KEY (roa_request_id) REFERENCES irdb_roarequest (id))')

Request Method: POST Request URL: http://rpki01.nic.ad.jp/rpki/roa/22/delete Django Version: 1.3.1 Exception Type: IntegrityError Exception Value:

(1451, 'Cannot delete or update a parent row: a foreign key constraint fails (irdbd.irdb_roarequestprefix, CONSTRAINT roa_request_id_refs_id_2efe3213 FOREIGN KEY (roa_request_id) REFERENCES irdb_roarequest (id))')

Exception Location: /usr/lib/python2.7/dist-packages/MySQLdb/connections.py in defaulterrorhandler, line 36 Python Executable: /usr/bin/python Python Version: 2.7.3 Python Path:

['/usr/local/etc/rpki', '/usr/share/pyshared/django', '/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']

Server time: Wed, 20 Feb 2013 06:39:20 +0000 Traceback Switch to copy-and-paste view

/usr/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response

                            response = callback(request, *callback_args, **callback_kwargs)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py in _wrapped_view

                    return view_func(request, *args, **kwargs)

    ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/rpki/gui/app/views.py in wrapped_fn

            return f(request, *args, **kwargs)

    ...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/rpki/gui/app/views.py in roa_delete

            roa.delete()

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/base.py in delete

            collector.delete()

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/deletion.py in decorated

                func(self, *args, **kwargs)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/deletion.py in delete

                query.delete_batch(pk_list, self.using)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/sql/subqueries.py in delete_batch

                self.do_query(self.model._meta.db_table, where, using=using)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/sql/subqueries.py in do_query

            self.get_compiler(using).execute_sql(None)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py in execute_sql

            cursor.execute(sql, params)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/backends/util.py in execute

                return self.cursor.execute(sql, params)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py in execute

                return self.cursor.execute(query, args)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py in execute

                self.errorhandler(self, exc, value)

    ...
▶ Local vars
/usr/lib/python2.7/dist-packages/MySQLdb/connections.py in defaulterrorhandler

        raise errorclass, errorvalue

    ...
▶ Local vars

Request information GET

No GET data POST Variable Value csrfmiddlewaretoken

u'850dac999b4e1224cb4422025e38d4f2'

FILES

No FILES data COOKIES Variable Value csrftoken

'850dac999b4e1224cb4422025e38d4f2'

sessionid

'edf95f7adc57031dc0033258708f94f4'

META Variable Value mod_wsgi.listener_port

'80'

HTTP_COOKIE

'csrftoken=850dac999b4e1224cb4422025e38d4f2; sessionid=edf95f7adc57031dc0033258708f94f4'

mod_wsgi.listener_host

''

SERVER_SOFTWARE

'Apache/2.2.22 (Ubuntu)'

SCRIPT_NAME

u''

mod_wsgi.handler_script

''

SERVER_SIGNATURE

'

Apache/2.2.22 (Ubuntu) Server at rpki01.nic.ad.jp Port 80
\n'

REQUEST_METHOD

'POST'

PATH_INFO

u'/rpki/roa/22/delete'

SERVER_PROTOCOL

'HTTP/1.1'

QUERY_STRING

''

CONTENT_LENGTH

'52'

HTTP_USER_AGENT

'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/20100101 Firefox/18.0'

HTTP_CONNECTION

'keep-alive'

HTTP_REFERER

'http://rpki01.nic.ad.jp/rpki/roa/22/delete'

SERVER_NAME

'rpki01.nic.ad.jp'

REMOTE_ADDR

'202.12.30.196'

mod_wsgi.request_handler

'wsgi-script'

wsgi.url_scheme

'http'

PATH_TRANSLATED

'/usr/local/share/rpki/wsgi/rpki.wsgi/rpki/roa/22/delete'

SERVER_PORT

'80'

wsgi.multiprocess

True

mod_wsgi.input_chunked

'0'

SERVER_ADDR

'202.12.30.91'

DOCUMENT_ROOT

'/var/www'

mod_wsgi.process_group

''

SCRIPT_FILENAME

'/usr/local/share/rpki/wsgi/rpki.wsgi'

SERVER_ADMIN

'webmaster@localhost'

wsgi.input

<mod_wsgi.Input object at 0xa994bef8>

HTTP_HOST

'rpki01.nic.ad.jp'

wsgi.multithread

True

mod_wsgi.callable_object

'application'

REQUEST_URI

'/rpki/roa/22/delete'

HTTP_ACCEPT

'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8'

wsgi.version

(1, 1)

GATEWAY_INTERFACE

'CGI/1.1'

wsgi.run_once

False

wsgi.errors

<mod_wsgi.Log object at 0xa9951278>

REMOTE_PORT

'50486'

HTTP_ACCEPT_LANGUAGE

'ja,en-us;q=0.7,en;q=0.3'

mod_wsgi.version

(3, 3)

CONTENT_TYPE

'application/x-www-form-urlencoded'

mod_wsgi.application_group

'127.0.1.1|'

mod_wsgi.script_reloading

'1'

wsgi.file_wrapper

''

CSRF_COOKIE

'850dac999b4e1224cb4422025e38d4f2'

HTTP_ACCEPT_ENCODING

'gzip, deflate'

Settings Using settings module settings Setting Value USE_L10N

False

USE_THOUSAND_SEPARATOR

False

LANGUAGE_CODE

'en-us'

ROOT_URLCONF

'rpki.gui.urls'

MANAGERS

()

DEFAULT_CHARSET

'utf-8'

STATIC_ROOT

'/usr/local/share/rpki/media'

TEST_DATABASE_CHARSET

None

MESSAGE_STORAGE

'django.contrib.messages.storage.user_messages.LegacyFallbackStorage'

DATABASE_HOST

''

IGNORABLE_404_STARTS

('/cgi-bin/', '/_vti_bin', '/_vti_inf')

SEND_BROKEN_LINK_EMAILS

False

URL_VALIDATOR_USER_AGENT

'Django/1.3.1 (http://www.djangoproject.com)'

STATICFILES_FINDERS

('django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder')

SESSION_COOKIE_DOMAIN

None

SESSION_COOKIE_NAME

'sessionid'

COMMENTS_MODERATORS_GROUP

None

TIME_INPUT_FORMATS

('%H:%M:%S', '%H:%M')

DATABASES

{'default': {'ENGINE': 'django.db.backends.mysql', 'HOST': '', 'NAME': 'irdbd', 'OPTIONS': {'init_command': 'SET storage_engine=INNODB'}, 'PASSWORD': '****', 'PORT': '', 'TEST_CHARSET': None, 'TEST_COLLATION': None, 'TEST_MIRROR': None, 'TEST_NAME': None, 'TIME_ZONE': 'UTC', 'USER': 'rpki'}}

TEST_DATABASE_NAME

None

FILE_UPLOAD_PERMISSIONS

None

FILE_UPLOAD_HANDLERS

('django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler')

DEFAULT_CONTENT_TYPE

'text/html'

APPEND_SLASH

True

FIRST_DAY_OF_WEEK

0

DATABASE_ROUTERS

[]

YEAR_MONTH_FORMAT

'F Y'

STATICFILES_STORAGE

'django.contrib.staticfiles.storage.StaticFilesStorage'

CACHES

{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': ''}}

SERVER_EMAIL

'root@localhost'

SESSION_COOKIE_PATH

'/'

USE_X_FORWARDED_HOST

False

IGNORABLE_404_ENDS

('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php')

MIDDLEWARE_CLASSES

('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.http.ConditionalGetMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

USE_I18N

True

THOUSAND_SEPARATOR

','

SECRET_KEY

'****'

LANGUAGE_COOKIE_NAME

'django_language'

FILE_UPLOAD_TEMP_DIR

None

TRANSACTIONS_MANAGED

False

LOGGING_CONFIG

'django.utils.log.dictConfig'

TEMPLATE_LOADERS

('django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader')

TEMPLATE_DEBUG

True

AUTHENTICATION_BACKENDS

('django.contrib.auth.backends.ModelBackend',)

TEST_DATABASE_COLLATION

None

FORCE_SCRIPT_NAME

None

CACHE_BACKEND

'locmem://'

SESSION_COOKIE_SECURE

False

CSRF_COOKIE_DOMAIN

None

FILE_CHARSET

'utf-8'

DEBUG

True

SESSION_FILE_PATH

None

DEFAULT_FILE_STORAGE

'django.core.files.storage.FileSystemStorage'

INSTALLED_APPS

['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.staticfiles', 'rpki.irdb', 'rpki.gui.app', 'rpki.gui.cacheview', 'rpki.gui.routeview', 'south']

LANGUAGES

(('ar', 'Arabic'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('bn', 'Bengali'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en', 'English'), ('en-gb', 'British English'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy-nl', 'Frisian'), ('ga', 'Irish'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hu', 'Hungarian'), ('id', 'Indonesian'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('nl', 'Dutch'), ('no', 'Norwegian'), ('nb', 'Norwegian Bokmal'), ('nn', 'Norwegian Nynorsk'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-cn', 'Simplified Chinese'), ('zh-tw', 'Traditional Chinese'))

DATABASE_ENGINE

''

DATABASE_NAME

''

COMMENTS_FIRST_FEW

0

PREPEND_WWW

False

SESSION_COOKIE_HTTPONLY

False

DATABASE_PORT

''

DEBUG_PROPAGATE_EXCEPTIONS

False

MONTH_DAY_FORMAT

'F j'

LOGIN_URL

'/accounts/login/'

SESSION_EXPIRE_AT_BROWSER_CLOSE

False

TIME_FORMAT

'P'

DATE_INPUT_FORMATS

('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y')

CSRF_COOKIE_NAME

'csrftoken'

EMAIL_HOST_PASSWORD

'****'

PASSWORD_RESET_TIMEOUT_DAYS

'****'

CACHE_MIDDLEWARE_ALIAS

'default'

SESSION_SAVE_EVERY_REQUEST

False

ADMIN_MEDIA_PREFIX

'/static/admin/'

NUMBER_GROUPING

0

SESSION_ENGINE

'django.contrib.sessions.backends.db'

CSRF_FAILURE_VIEW

'django.views.csrf.csrf_failure'

COMMENTS_SKETCHY_USERS_GROUP

None

LOGIN_REDIRECT_URL

'/accounts/profile/'

LOGGING

{'disable_existing_loggers': False, 'handlers': {'mail_admins': {'class': 'django.utils.log.AdminEmailHandler', 'level': 'ERROR'}}, 'loggers': {'django.request': {'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True}}, 'version': 1}

CACHE_MIDDLEWARE_KEY_PREFIX

''

LOCALE_PATHS

()

TEMPLATE_STRING_IF_INVALID

''

COMMENTS_ALLOW_PROFANITIES

False

LOGOUT_URL

'/accounts/logout/'

EMAIL_USE_TLS

False

TEMPLATE_DIRS

()

FIXTURE_DIRS

()

EMAIL_HOST

'localhost'

DATE_FORMAT

'N j, Y'

MEDIA_ROOT

''

ADMINS

()

FORMAT_MODULE_PATH

None

DEFAULT_FROM_EMAIL

'webmaster@localhost'

STATICFILES_DIRS

()

MEDIA_URL

''

DATETIME_FORMAT

'N j, Y, P'

EMAIL_SUBJECT_PREFIX

'[Django] '

DISALLOWED_USER_AGENTS

()

ALLOWED_INCLUDE_ROOTS

()

DECIMAL_SEPARATOR

'.'

SHORT_DATE_FORMAT

'm/d/Y'

DATABASE_USER

''

TEST_RUNNER

'django.test.simple.DjangoTestSuiteRunner'

TIME_ZONE

'UTC'

FILE_UPLOAD_MAX_MEMORY_SIZE

2621440

EMAIL_BACKEND

'django.core.mail.backends.smtp.EmailBackend'

DEFAULT_TABLESPACE

''

TEMPLATE_CONTEXT_PROCESSORS

('django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.request', 'django.core.context_processors.static')

SESSION_COOKIE_AGE

1209600

SETTINGS_MODULE

'settings'

USE_ETAGS

False

LANGUAGES_BIDI

('he', 'ar', 'fa')

DEFAULT_INDEX_TABLESPACE

''

INTERNAL_IPS

()

STATIC_URL

'/media/'

EMAIL_PORT

25

SHORT_DATETIME_FORMAT

'm/d/Y P'

ABSOLUTE_URL_OVERRIDES

{}

DATABASE_OPTIONS

{}

CACHE_MIDDLEWARE_SECONDS

600

BANNED_IPS

()

DATETIME_INPUT_FORMATS

('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M', '%m/%d/%y')

DATABASE_PASSWORD

'****'

ADMIN_FOR

()

COMMENTS_BANNED_USERS_GROUP

None

EMAIL_HOST_USER

''

PROFANITIES_LIST

'****'

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page.

Trac ticket #418 component gui priority minor, owner melkins, created by taiji-k on 2013-02-20T07:19:28Z, last modified 2013-02-22T03:28:39Z

sraustein commented 11 years ago

This is strange, because Django's default behavior is to delete objects when the target of the foreign key is deleted. The irdb itself doesn't have any special annotations on the foreign key linked ROARequestPrefix to ROARequest, so deleting a ROARequest object should cascade the deletes to the related ROARequestPrefix objects as well.

Trac comment by melkins on 2013-02-21T03:23:44Z

sraustein commented 11 years ago

You are running Django 1.3.1 so I'm wondering if you are getting bit by this bug that was fixed in a later release https://code.djangoproject.com/ticket/17140

Is it possible for you to remove the Ubuntu python-django package and use easy_install or pip to install either 1.3.7 or newer?

Trac comment by melkins on 2013-02-21T04:06:23Z

sraustein commented 11 years ago

It would be good to know as soon as possible whether this does indeed fix the problem, as it may suggest tweaks we should make to the Ubuntu rpki-ca package before next week's hackathon in Singapore. Not sure how to hack .deb depending on pip install but will think of something if needed.

Trac Ticket System tickets@trac.rpki.net wrote:

418: backtrace when deleting roa in hackathon2

----------------------+---------------------- Reporter: taiji-k | Owner: melkins Type: defect | Status: accepted Priority: minor | Component: gui Resolution: | Keywords: Blocked By: | Blocking: ----------------------+----------------------

Comment (by melkins):

You are running Django 1.3.1 so I'm wondering if you are getting bit by this bug that was fixed in a later release https://code.djangoproject.com/ticket/17140

Is it possible for you to remove the Ubuntu python-django package and use easy_install or pip to install either 1.3.7 or newer?

Sent from my phone. Please excuse brevity and typos.

Trac comment by sra on 2013-02-21T04:26:55Z

sraustein commented 11 years ago

I think think is going to be necessary anyway, because the version of South that is shipped with Ubuntu 12.04LTS is too old, so the configure script fails.

{{{ $ apt-cache policy python-django-south python-django-south: Installed: (none) Candidate: 0.7.3-1ubuntu1 Version table: 0.7.3-1ubuntu1 0 500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages }}}

Trac comment by melkins on 2013-02-21T04:33:36Z

sraustein commented 11 years ago

Fair point, although in the Debian universe it won't be ./configure that fails on the installation machine (build and installation dependencies are totally separate, and ./configure only runs on build machine).

I suspect this will end up being something like:

  1. Adding an installation dependency on python-pip, to make sure it's available, then
  2. Adding some code to rpki-ca.postinst to check for Django and South, install them if both possible and needed, and whine then cause installation to fail if needed and not possible (eg, because installation is happening without Internet available).

Not something I expect Ubuntu or Debian package maintainers to accept, but hardly the only unacceptable kludge of that kind in the current packaging. As with other such issues, we can deal with cleaning this up to the satistfaction of the distribution maintainers once we have the basics working (and have more time on our hands than we do at the moment).

I may attempt to code this on this evening's flight to Singapore (sitting in Narita at the gate now). Then again, I may just read a book. Holler if you have a better idea.

Trac comment by sra on 2013-02-21T07:36:43Z

sraustein commented 11 years ago

Bingo.

It seems long way for me to be a person who can handle it like you both.

After installing Django-1.4.5, removing ROA on GUI doesn't show exceptions.

aptitude remove python-django

easy_install django

: Installed /usr/local/lib/python2.7/dist-packages/Django-1.4.5-py2.7.egg

/etc/init.d/apache2 restart

Replying to [comment:3 sra]:

It would be good to know as soon as possible whether this does indeed fix the problem, as it may suggest tweaks we should make to the Ubuntu rpki-ca package before next week's hackathon in Singapore. Not sure how to hack .deb depending on pip install but will think of something if needed.

Trac comment by taiji-k on 2013-02-21T13:02:47Z

sraustein commented 11 years ago

I've updated the installation page.

Trac comment by taiji-k on 2013-02-21T13:17:23Z

sraustein commented 11 years ago

I think it may be better just to set up our own apt repository with newer versions of required software. As a test, I rebuilt python-django and python-django-south from the Quantal release and set up a repository:

deb http://sigpipe.org/rpki rpki main

Trac comment by melkins on 2013-02-21T17:59:54Z

sraustein commented 11 years ago

Closed with resolution worksforme