Avoid the pattern sql select/delete

Bug #1496586 reported by Cedric Brandily
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Expired
Wishlist
Unassigned

Bug Description

The following pattern:

 obj = query.filter(...).one()
 context.session.delete(obj)

 is racy because obj can be deleted between the select and the delete, we should prefer when possible the pattern:

 count = query.filter(...).delete(synchronize_session=False)
 if not count:
   raise NotFound

Tags: db
Changed in neutron:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

This can't be applied everywhere blindly:

http://eavesdrop.openstack.org/irclogs/%23openstack-neutron/%23openstack-neutron.2015-09-16.log.html#t2015-09-16T22:52:04

So it's good to have a look around, but let's not start a crusade :)

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

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

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (master)

Change abandoned by Armando Migliaccio (<email address hidden>) on branch: master
Review: https://review.openstack.org/224351
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

This bug is > 180 days without activity. We are unsetting assignee and milestone and setting status to Incomplete in order to allow its expiry in 60 days.

If the bug is still valid, then update the bug status.

Changed in neutron:
assignee: Cedric Brandily (cbrandily) → nobody
status: In Progress → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
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.