[ovs-dev] [PATCH] ovn: Take advantage of OVSDB garbage collection in OVN_Northbound schema.

Ben Pfaff blp at nicira.com
Fri Jun 26 18:37:35 UTC 2015


On Fri, Jun 26, 2015 at 05:20:16PM +0000, Aaron Rosen wrote:
> I just tested out this patch and it seems to work as expected for
> me. I do have a few quick questions/thoughts.
> 
> - One thing I noticed is if I create a logical_port but don't append
> the port.uuid to the Logical_Switch.ports column it seems like the
> port isn't showing up in ovsdb.  I'm not sure if this is expected or
> I'm incorrect.

That's a consequence of the garbage collection.  A Logical_Port that
isn't attached to a Logical_Switch gets destroyed.  That's true if it
was previously attached to a Logical_Switch that was just deleted, or if
it was created within the current transaction and never attached to a
Logical_Switch.

> - Another thing I was thinking about is if requiring the caller to
> query ovsdb for the logical_switch to obtain the switch_ports and then
> appending the newly create logical port could be problematic. For one
> it seems like we need to lock ovsdb for concurrent operations here.  

OVSDB doesn't support locking, so the equivalent that allows one to
avoid problems with "dirty reads" is to verify that the ports are the
expected set (the set before the transaction started) and make the
transaction abort if it isn't correct.  With the OSVDB Python IDL,
that's just a matter of calling Row.verify() on the column in question
before modifying the column.  (If the transaction aborts, then you just
retry it.)

This is the purpose of the nbrec_logical_switch_verify_ports() calls in
do_lport_add() and remove_lport() in ovn-nbctl.c as modified by this
commit, by the way.

> I was wondering if it would be possible to keep previous schema where
> the logical_port stores a reference to it's logical_switch. Though,
> when the logical_switch is deleted we would cascade the deletes of the
> logical_ports on that switch? 

OVSDB only supports cascading with the schema in the form used by this
comit.

> I also think it feels more natural to have a reference from the
> logical_port to logical_switch because now it seems like the schema
> allows one to create a logical_port without a logical_switch? Perhaps
> ovsdb can't currently work in this way which you were explaining in
> your commit message though I just wanted to make sure.

With this schema, an unattached logical_port can exist temporarily
within a transaction but transaction commit will delete it, so that the
unattached logical_port will never be visible to other clients (or in
the database log).



More information about the dev mailing list