Deadlock on quota_usages

Bug #1308715 reported by Vish Ishaya
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Vish Ishaya
Havana
Fix Released
Undecided
Unassigned
Icehouse
Fix Released
High
Vish Ishaya

Bug Description

We are getting deadlocks for concurrent quota reservations that we did not see in grizzly:

see https://bugs.launchpad.net/nova/+bug/1283987

The deadlock handling needs to be fixed as per above, but we shouldn't be deadlocking, here. It seems this is due to bad indexes in the database:

mysql> show index from quota_usages;
+--------------+------------+---------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------+------------+---------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| quota_usages | 0 | PRIMARY | 1 | id | A | 8 | NULL | NULL | | BTREE | | |
| quota_usages | 1 | ix_quota_usages_project_id | 1 | project_id | A | 8 | NULL | NULL | YES | BTREE | | |
| quota_usages | 1 | ix_quota_usages_user_id_deleted | 1 | user_id | A | 8 | NULL | NULL | YES | BTREE | | |
| quota_usages | 1 | ix_quota_usages_user_id_deleted | 2 | deleted | A | 8 | NULL | NULL | YES | BTREE | | |
+--------------+------------+---------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
4 rows in set (0.01 sec)

mysql> explain select * from quota_usages where project_id='foo' and user_id='bar' and deleted=0;
+----+-------------+--------------+------+------------------------------------------------------------+----------------------------+---------+-------+------+------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+------------------------------------------------------------+----------------------------+---------+-------+------+------------------------------------+
| 1 | SIMPLE | quota_usages | ref | ix_quota_usages_project_id,ix_quota_usages_user_id_deleted | ix_quota_usages_project_id | 768 | const | 1 | Using index condition; Using where |
+----+-------------+--------------+------+------------------------------------------------------------+----------------------------+---------+-------+------+------------------------------------+
1 row in set (0.00 sec)

We should have an index on project_id/deleted and project_id/user_id/deleted instead of the current values.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

alternatively we could clean up the _get_user_quotas and _get_project_quotas to be a single query:

https://github.com/openstack/nova/blob/0e080bdcdbf44286f2e01a4546378442580dbce5/nova/db/sqlalchemy/api.py#L3033

Revision history for this message
Vish Ishaya (vishvananda) wrote :
Changed in nova:
importance: Undecided → High
status: New → In Progress
assignee: nobody → Vish Ishaya (vishvananda)
summary: - Deadlock on quota_usages due to misisng index
+ Deadlock on quota_usages
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/88081
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=da1fa5dc93e6e64d397e8d00769e34828669e010
Submitter: Jenkins
Branch: master

commit da1fa5dc93e6e64d397e8d00769e34828669e010
Author: Vishvananda Ishaya <email address hidden>
Date: Wed Apr 16 13:41:17 2014 -0700

    Use one query instead of two for quota_usages

    The second query was unnecessary and not using a proper index. It
    seemed to be contributing to a deadlock issue as well.

    Change-Id: I1031451b25140d71380c8149d3c83827eec0d4a9
    Closes-Bug: #1308715
    Co-Authored-by: Chris Behrens <email address hidden>

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to nova (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/92488

tags: added: icehouse-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/icehouse)

Reviewed: https://review.openstack.org/92488
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=bedb66f1117764e10c0b179171f0772cd08cdf80
Submitter: Jenkins
Branch: stable/icehouse

commit bedb66f1117764e10c0b179171f0772cd08cdf80
Author: Vishvananda Ishaya <email address hidden>
Date: Wed Apr 16 13:41:17 2014 -0700

    Use one query instead of two for quota_usages

    The second query was unnecessary and not using a proper index. It
    seemed to be contributing to a deadlock issue as well.

    Change-Id: I1031451b25140d71380c8149d3c83827eec0d4a9
    Closes-Bug: #1308715
    Co-Authored-by: Chris Behrens <email address hidden>
    (cherry picked from commit da1fa5dc93e6e64d397e8d00769e34828669e010)

Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-1
status: Fix Committed → Fix Released
Revision history for this message
Sean Dague (sdague) wrote :

Dropped from ER tracking

tags: added: havana-backport-potentialal icehouse-backport-potenti
removed: icehouse-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/104116

tags: added: havana-backport-potential icehouse-backport-potential
removed: havana-backport-potentialal icehouse-backport-potenti
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/havana)

Reviewed: https://review.openstack.org/104116
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0f5032be9c7a9af3a1e73d49f8c07f9c1c04519d
Submitter: Jenkins
Branch: stable/havana

commit 0f5032be9c7a9af3a1e73d49f8c07f9c1c04519d
Author: Vishvananda Ishaya <email address hidden>
Date: Wed Apr 16 13:41:17 2014 -0700

    Use one query instead of two for quota_usages

    The second query was unnecessary and not using a proper index. It
    seemed to be contributing to a deadlock issue as well.

    Change-Id: I1031451b25140d71380c8149d3c83827eec0d4a9
    Closes-Bug: #1308715
    Co-Authored-by: Chris Behrens <email address hidden>
    (cherry picked from commit da1fa5dc93e6e64d397e8d00769e34828669e010)
    (cherry picked from commit bedb66f1117764e10c0b179171f0772cd08cdf80)

tags: added: in-stable-havana
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-1 → 2014.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.