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

IntegrityError when dispatching multiple swarms #190

Open
ghost opened this issue Jun 6, 2016 · 1 comment
Open

IntegrityError when dispatching multiple swarms #190

ghost opened this issue Jun 6, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 6, 2016

Originally reported by: Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco)


Using the cli to dispatch 6 swarms, I encountered this error.

Traceback (most recent call last):
  File "/app/.heroku/venv/lib/python2.7/site-packages/vr/server/tasks.py", line 72, in wrapper
    func(*args, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/vr/server/tasks.py", line 511, in swarm_release
    pl.save()
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save
    force_update=force_update, update_fields=update_fields)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/base.py", line 846, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/base.py", line 885, in _do_insert
    using=using, raw=raw)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/query.py", line 920, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
IntegrityError: duplicate key value violates unique constraint "deployment_portlock_host_id_3a973353e3b27e11_uniq"
DETAIL:  Key (host_id, port)=(124, 5006) already exists.

It's not clear to me what would trigger this error. Here's what the event log looked like.

Screen Shot 2016-06-06 at 16.25.25.png


@ghost
Copy link
Author

ghost commented Jun 7, 2016

Original comment by Brent Tubbs (Bitbucket: btubbs, GitHub: btubbs):


It's a race condition between two swarming operations. Both are trying to grab the same host+port for one of their procs. The IntegrityError is saying "sorry, the database forbids that", and saving you from the much worse problem of two procs trying to use the same port on the same host.

You could catch it at the level that decides which port to use and have it try a different one.

@ghost ghost added major bug labels Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants