From 54d67bac7dc128c348372a9c411316afe2d1507e Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Wed, 18 Feb 2015 19:25:27 +0200 Subject: [PATCH] VMWare NSXv: id fields should be nullable To handle concurrency issues when two neutron nodes initialize at the same time, we use the following solution: - Each neutron node attempts to create a record with id value=NULL - One which inserts successfully, resumes to create the resource and once the resource is created, it updates its id in the database - One which fails with duplicate entry exception, busy-waits until the id field is populated, of terminates on timeout. Relevant resources are internal edges, and internal networks. To implement the above, id fields should be nullable. Change-Id: Iff94678ab341ccb1310d6b6efc53a52bd3bb9240 Partially-Implements: blueprint vmware-nsx-v --- .../alembic_migrations/versions/4dbe243cd84d_nsxv.py | 4 ++-- neutron/plugins/vmware/dbexts/nsxv_models.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/neutron/db/migration/alembic_migrations/versions/4dbe243cd84d_nsxv.py b/neutron/db/migration/alembic_migrations/versions/4dbe243cd84d_nsxv.py index 3fbb7ea5f..6c17bfae6 100644 --- a/neutron/db/migration/alembic_migrations/versions/4dbe243cd84d_nsxv.py +++ b/neutron/db/migration/alembic_migrations/versions/4dbe243cd84d_nsxv.py @@ -57,14 +57,14 @@ def upgrade(): 'nsxv_internal_networks', sa.Column('network_purpose', internal_network_purpose_enum, nullable=False), - sa.Column('network_id', sa.String(length=36), nullable=False), + sa.Column('network_id', sa.String(length=36), nullable=True), sa.ForeignKeyConstraint(['network_id'], ['networks.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('network_purpose')) op.create_table( 'nsxv_internal_edges', sa.Column('ext_ip_address', sa.String(length=64), nullable=False), - sa.Column('router_id', sa.String(length=36), nullable=False), + sa.Column('router_id', sa.String(length=36), nullable=True), sa.Column('purpose', internal_edge_purpose_enum, nullable=True), sa.PrimaryKeyConstraint('ext_ip_address')) op.create_table( diff --git a/neutron/plugins/vmware/dbexts/nsxv_models.py b/neutron/plugins/vmware/dbexts/nsxv_models.py index 369bfa7f3..bac20d8d0 100644 --- a/neutron/plugins/vmware/dbexts/nsxv_models.py +++ b/neutron/plugins/vmware/dbexts/nsxv_models.py @@ -84,7 +84,7 @@ class NsxvInternalNetworks(model_base.BASEV2): primary_key=True) network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id", ondelete="CASCADE"), - nullable=False) + nullable=True) class NsxvInternalEdges(model_base.BASEV2): @@ -93,7 +93,7 @@ class NsxvInternalEdges(model_base.BASEV2): __tablename__ = 'nsxv_internal_edges' ext_ip_address = sa.Column(sa.String(64), primary_key=True) - router_id = sa.Column(sa.String(36), nullable=False) + router_id = sa.Column(sa.String(36), nullable=True) purpose = sa.Column( sa.Enum(nsxv_constants.INTER_EDGE_PURPOSE, name='nsxv_internal_edges_purpose')) -- 2.45.2