[2.0b1] django.db.utils.IntegrityError: duplicate key value violates unique constraint "maasserver_space_pkey"

Bug #1567176 reported by Andres Rodriguez on 2016-04-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Critical
Unassigned

Bug Description

2016-04-06 22:09:59 [-] Failed to register rack controller 'None' into the database. Connection has been dropped.
        Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1184, in gotResult
            _inlineCallbacks(r, g, deferred)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
            result = result.throwExceptionIntoGenerator(g)
          File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
            return g.throw(self.type, self.value, self.tb)
          File "/usr/lib/python3/dist-packages/maasserver/rpc/regionservice.py", line 570, in register
            log.err(exc, msg)
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/maasserver/rpc/regionservice.py", line 522, in register
            transactional(rack_controller.update_interfaces), interfaces)
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 246, in inContext
            result = inContext.theWork()
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 262, in <lambda>
            inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 81, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 516, in call_within_transaction
            return func_outside_txn(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 343, in retrier
            return func(*args, **kwargs)
          File "/usr/lib/python3.5/contextlib.py", line 30, in inner
            return func(*args, **kwds)
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 3052, in update_interfaces
            interface = self._update_interface(name, interfaces[name])
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 3085, in _update_interface
            return self._update_physical_interface(name, config)
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 3142, in _update_physical_interface
            update_ip_addresses = self._update_links(interface, config["links"])
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 3393, in _update_links
            "space": Space.objects.get_default_space(),
          File "/usr/lib/python3/dist-packages/maasserver/models/space.py", line 84, in get_default_space
            'updated': now,
          File "/usr/lib/python3/dist-packages/django/db/models/manager.py", line 127, in manager_method
            return getattr(self.get_queryset(), name)(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 407, in get_or_create
            return self._create_object_from_params(lookup, params)
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 447, in _create_object_from_params
            six.reraise(*exc_info)
          File "/usr/lib/python3/dist-packages/django/utils/six.py", line 686, in reraise
            raise value
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 439, in _create_object_from_params
            obj = self.create(**params)
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 348, in create
            obj.save(force_insert=True, using=self.db)
          File "/usr/lib/python3/dist-packages/maasserver/models/space.py", line 163, in save
            super().save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/models/cleansave.py", line 29, in save
            return super(CleanSave, self).save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/models/timestampedmodel.py", line 64, in save
            return super(TimestampedModel, self).save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 734, in save
            force_update=force_update, update_fields=update_fields)
          File "/usr/lib/python3/dist-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 "/usr/lib/python3/dist-packages/django/db/models/base.py", line 846, in _save_table
            result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 885, in _do_insert
            using=using, raw=raw)
          File "/usr/lib/python3/dist-packages/django/db/models/manager.py", line 127, in manager_method
            return getattr(self.get_queryset(), name)(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/db/models/query.py", line 920, in _insert
            return query.get_compiler(using=using).execute_sql(return_id)
          File "/usr/lib/python3/dist-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
            cursor.execute(sql, params)
          File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 64, in execute
            return self.cursor.execute(sql, params)
          File "/usr/lib/python3/dist-packages/django/db/utils.py", line 98, in __exit__
            six.reraise(dj_exc_type, dj_exc_value, traceback)
          File "/usr/lib/python3/dist-packages/django/utils/six.py", line 685, in reraise
            raise value.with_traceback(tb)
          File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 64, in execute
            return self.cursor.execute(sql, params)
        django.db.utils.IntegrityError: duplicate ke

Related branches

Changed in maas:
milestone: none → 2.0.0
importance: Undecided → Critical
Changed in maas:
status: New → Triaged
Changed in maas:
status: Triaged → Fix Committed
LaMont Jones (lamont) wrote :

We need to see the data base at a time when this fails, along with the complete traceback from the logs.

Changed in maas:
status: Fix Committed → Incomplete
summary: - [2.0 beta 1] django.db.utils.IntegrityError: duplicate key value
- violates unique constraint "maasserver_space_pkey"
+ [2.0b1] django.db.utils.IntegrityError: duplicate key value violates
+ unique constraint "maasserver_space_pkey"
Andres Rodriguez (andreserl) wrote :

We believe this is no longer an issue, as such marking this as Invalid

Changed in maas:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers