<div dir="ltr">With Ussuri I'm hitting this in the neutron server:<div><br></div><div>Failed to create a duplicate DefaultSecurityGroup: for attribute(s) ['PRIMARY'] with value(s) 11447be9beda4bf78dab27cdb75058e2<br></div><div>pymysql.err.IntegrityError: (1062, "Duplicate entry '11447be9beda4bf78dab27cdb75058e2' for key 'PRIMARY'")<br></div><div>oslo_db.exception.DBDuplicateEntry: (pymysql.err.IntegrityError) (1062, "Duplicate entry '11447be9beda4bf78dab27cdb75058e2' for key 'PRIMARY'")<br>[SQL: INSERT INTO default_security_group (project_id, security_group_id) VALUES (%(project_id)s, %(security_group_id)s)]<br>[parameters: {'project_id': '11447be9beda4bf78dab27cdb75058e2', 'security_group_id': '9f3a473c-b08a-4cf2-8327-10ecc8b87301'}]<br></div><div>neutron_lib.objects.exceptions.NeutronDbObjectDuplicateEntry: Failed to create a duplicate DefaultSecurityGroup: for attribute(s) ['PRIMARY'] with value(s) 11447be9beda4bf78dab27cdb75058e2<br></div><div><br></div><div>(Those are all, I believe, reports of the same problem, at different levels of the stack.)</div><div><br></div><div>IIUC, this is triggered by my Neutron driver calling</div><div><br></div><div>        rules = self.db.get_security_group_rules(<br>            context, filters={'security_group_id': sgids}<br>        )<br></div><div><br></div><div>where the context has project_id 11447be9beda4bf78dab27cdb75058e2.  Deep down inside that call, Neutron tries to ensure that there is a default security group for that project, and somehow that hits the reported exception.</div><div><br></div><div>Here's the code in securitygroups_db.py:</div><div><br></div><div>    def _ensure_default_security_group(self, context, tenant_id):<br>        """Create a default security group if one doesn't exist.<br><br>        :returns: the default security group id for given tenant.<br>        """<br>        default_group_id = self._get_default_sg_id(context, tenant_id)<br>        if default_group_id:<br>            return default_group_id<br><br>        security_group = {<br>            'security_group':<br>                {'name': 'default',<br>                 'tenant_id': tenant_id,<br>                 'description': _('Default security group')}<br>        }<br>        return self.create_security_group(context, security_group,<br>                                          default_sg=True)['id']<br></div><div><br></div><div>Obviously it checks first if the default SG already exists for the project, before creating it if not.  So why would that code hit the duplicate exception as shown above?</div><div><br></div><div>Any ideas welcome!</div><div><br></div><div>Best wishes,</div><div>     Neil</div><div><br></div></div>