instance_actions table should have a UniqueConstraint on instance_uuid and request_id

Bug #1496146 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Low
Pushkar Umaranikar

Bug Description

An instance action should be unique per instance uuid and request ID. That's pointed out in the data model:

https://github.com/openstack/nova/blob/master/nova/db/sqlalchemy/models.py#L1241

"The intention is that there will only be one of these per user request. A lookup by (instance_uuid, request_id) should always return a single result."

It's also enforced in the API:

https://github.com/openstack/nova/blob/master/nova/db/sqlalchemy/api.py#L5719

def action_get_by_request_id(context, instance_uuid, request_id):
    """Get the action by request_id and given instance."""
    action = _action_get_by_request_id(context, instance_uuid, request_id)
    return action

But that is not actually enforced in the schema using a UniqueConstraint.

This is a low priority but it's technically something we should have in the data model/schema.

Tags: db
Revision history for this message
Matt Riedemann (mriedem) wrote :

Note that any database migration which adds a UniqueConstraint here would have to check for duplicates and drop them before attempting to create the constraint.

Changed in nova:
importance: Undecided → Low
status: New → Triaged
Akira KAMIO (kamio)
Changed in nova:
assignee: nobody → Akira KAMIO (akamio)
Revision history for this message
robin (robinflx25) wrote :

when i made a lookup in nova database;instance_actions table its showing the unique action..

1.I started the vm
2.shutoff the VM
3.again started the same VM.

Below is the entries made in the db (nova ) and in the table (instance_actions).The request_id is unique for the particular VM

instance_uuid | request_id | action |
37b1b32f-ecbd-4079-960f-80142c4a77dd | req-db08ba63-806f-4d1c-a199-3ef87ce84b0c | start |
| 37b1b32f-ecbd-4079-960f-80142c4a77dd | req-e185f9f8-b61c-4be1-baca-7a8967de68f9 | stop |
| 37b1b32f-ecbd-4079-960f-80142c4a77dd | req-92794d3c-08ef-4827-81e0-981ea28942f9 | start |

Please correct me if i am wrong.....

Changed in nova:
assignee: Akira KAMIO (akamio) → nobody
Changed in nova:
assignee: nobody → Rebecca Finn (rebeccax-finn)
Changed in nova:
assignee: Rebecca Finn (rebeccax-finn) → nobody
Changed in nova:
assignee: nobody → Pushkar Umaranikar (pushkar-umaranikar)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Change abandoned by Michael Still (<email address hidden>) on branch: master
Review: https://review.openstack.org/365181
Reason: This patch has been sitting unchanged for more than 12 weeks. I am therefore going to abandon it to keep the review queue sane. Please feel free to restore the change if you're still working on it.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Sean Dague (<email address hidden>) on branch: master
Review: https://review.openstack.org/365181
Reason: This review is > 4 weeks without comment, and is not mergable in it's current state. 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.

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.