Database deletions should use delete orphan

Bug #1096549 reported by Gary Kotton
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Senhua Huang

Bug Description

Following a review on cascade='delete', the following was suggested:

"Typically, cascade is usually left at its default, or configured as all, delete-orphan, indicating the child objects should be treated as “owned” by the parent."

Tags: db
Revision history for this message
Senhua Huang (senhuang) wrote :

Hi Gary,

Do you mean we should add "delete-orphan" to cascade in the following lines (141-146) of codes in quantum/db/models_v2.py:
dns_nameservers = orm.relationship(DNSNameServer, backref='subnet', cascade='delete')
routes = orm.relationship(Route, backref='subnet', cascade='delete')

and the following lines (68-75) in quantum/db/security_groups_db.py:
security_group = orm.relationship(securityGroup, backref=orm.backref('rules', cascade='all, delete'), primaryjoin="SecurityGroup.id==SecurityGroupRule.security_group_id")
source_group = orm.relationship(SecurityGroup, backref=orm.backref('source_rules, cascade='all,delete'), primaryjoin="SecurityGroup.id==SecurityGroupRule.source_group_id")?

According to the online document of SqlAlchemy, "delete-orphan cascade implies that each child object can only have one parent at a time, so is configured in the vast majority of cases on a one-to-many relationship." Is this the case here for the relationship defined by dns_nameservers, routes, security_group, and source_group? Thanks!

Revision history for this message
yong sheng gong (gongysh) wrote :

Hi,
When it means owned by parent, all, delete-orphan should be used.
dns_nameservers, routers should be owned by one parent. but source_groups should be not this case(IMHO). securitygrouprules should be owned by only security group.

tags: added: db
Changed in quantum:
importance: Undecided → Low
importance: Low → Medium
status: New → Confirmed
Senhua Huang (senhuang)
Changed in quantum:
assignee: nobody → Senhua Huang (senhuang)
Revision history for this message
dan wendlandt (danwent) wrote :

note: this change should not be merged into grizzly, but you are free to work on it for later submission to havana.

Revision history for this message
Senhua Huang (senhuang) wrote :

okay. thanks!

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/24501

Changed in quantum:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (master)

Reviewed: https://review.openstack.org/24501
Committed: http://github.com/openstack/quantum/commit/377f78fa55988a92674bd940130ff8d15f3ec521
Submitter: Jenkins
Branch: master

commit 377f78fa55988a92674bd940130ff8d15f3ec521
Author: Senhua Huang <email address hidden>
Date: Thu Mar 14 19:05:38 2013 -0700

    Adds delete-orphan to database deletion.

    Change-Id: I3570c812c042365e68eef3b5463899afa85eb9fd
    Fixes: bug #1096549

Changed in quantum:
status: In Progress → Fix Committed
Changed in quantum:
milestone: none → havana-1
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: havana-1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.