diff --git a/neutron/db/db_base_plugin_common.py b/neutron/db/db_base_plugin_common.py index 2ea013d22ce..cdcd347aa12 100644 --- a/neutron/db/db_base_plugin_common.py +++ b/neutron/db/db_base_plugin_common.py @@ -107,6 +107,12 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin): subnet_id=subnet_id ) context.session.add(allocated) + # NOTE(kevinbenton): We add this to the session info so the sqlalchemy + # object isn't immediately garbage collected. Otherwise when the + # fixed_ips relationship is referenced a new persistent object will be + # added to the session that will interfere with retry operations. + # See bug 1556178 for details. + context.session.info.setdefault('allocated_ips', []).append(allocated) def _make_subnet_dict(self, subnet, fields=None, context=None): res = {'id': subnet['id'], diff --git a/neutron/db/models_v2.py b/neutron/db/models_v2.py index 51a483c0084..dc909b13afa 100644 --- a/neutron/db/models_v2.py +++ b/neutron/db/models_v2.py @@ -119,7 +119,8 @@ class Port(model_base.BASEV2, HasId, HasTenant): network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"), nullable=False) fixed_ips = orm.relationship(IPAllocation, backref='port', lazy='joined', - passive_deletes='all') + cascade='all, delete-orphan') + mac_address = sa.Column(sa.String(32), nullable=False) admin_state_up = sa.Column(sa.Boolean(), nullable=False) status = sa.Column(sa.String(16), nullable=False)