Steps to reproduce:
We create multiple shares at the same time, and run in different share-api services.
# manila create NFS 1
# manila create NFS 1
# manila create NFS 1
# manila create NFS 1
mysql> select * from quota_usages;
+---------------------+---------------------+------------+---------+----+----------------------------------+----------------------------------+----------------+--------+----------+---------------+--------------------------------------+
| created_at | updated_at | deleted_at | deleted | id | user_id | project_id | resource | in_use | reserved | until_refresh | share_type_id |
+---------------------+---------------------+------------+---------+----+----------------------------------+----------------------------------+----------------+--------+----------+---------------+--------------------------------------+
| 2017-07-25 20:29:53 | 2017-07-27 02:42:01 | NULL | 0 | 1 | d450d728853a452d9f20b8ff98b9f279 | e23850eeb91d4fa3866af634223e454c | gigabytes | 2 | 0 | NULL | NULL |
| 2017-07-25 20:29:53 | 2017-07-27 02:42:01 | NULL | 0 | 2 | d450d728853a452d9f20b8ff98b9f279 | e23850eeb91d4fa3866af634223e454c | shares | 2 | 0 | NULL | NULL |
| 2017-07-25 20:32:43 | 2017-07-27 02:42:01 | NULL | 0 | 3 | NULL | e23850eeb91d4fa3866af634223e454c | gigabytes | 2 | 0 | NULL | 14ff61bc-a3b1-4c3d-9e2e-e5074e01531e |
| 2017-07-25 20:32:43 | 2017-07-27 02:42:01 | NULL | 0 | 4 | NULL | e23850eeb91d4fa3866af634223e454c | shares | 2 | 0 | NULL | 14ff61bc-a3b1-4c3d-9e2e-e5074e01531e |
| 2017-07-26 03:02:45 | 2017-07-26 03:03:29 | NULL | 0 | 5 | NULL | e23850eeb91d4fa3866af634223e454c | gigabytes | 0 | 0 | NULL | 5eca3a82-abfc-4adc-a78e-886669bc0e36 |
| 2017-07-26 03:02:45 | 2017-07-26 03:03:29 | NULL | 0 | 6 | NULL | e23850eeb91d4fa3866af634223e454c | shares | 0 | 0 | NULL | 5eca3a82-abfc-4adc-a78e-886669bc0e36 |
| 2017-07-26 03:02:55 | 2017-07-26 03:03:07 | NULL | 0 | 7 | NULL | e23850eeb91d4fa3866af634223e454c | gigabytes | 0 | 0 | NULL | 16cd9d7f-1d2e-4fb8-a273-a43f8c6bf245 |
| 2017-07-26 03:02:55 | 2017-07-26 03:03:07 | NULL | 0 | 8 | NULL | e23850eeb91d4fa3866af634223e454c | shares | 0 | 0 | NULL | 16cd9d7f-1d2e-4fb8-a273-a43f8c6bf245 |
| 2017-07-26 07:46:09 | 2017-07-26 09:46:00 | NULL | 0 | 9 | d450d728853a452d9f20b8ff98b9f279 | e23850eeb91d4fa3866af634223e454c | share_networks | 0 | 0 | NULL | NULL |
| 2017-07-26 09:32:15 | 2017-07-26 09:32:41 | NULL | 0 | 10 | NULL | e23850eeb91d4fa3866af634223e454c | gigabytes | 0 | 0 | NULL | 14ff61bc-a3b1-4c3d-9e2e-e5074e01531e |
| 2017-07-26 09:32:15 | 2017-07-26 09:32:41 | NULL | 0 | 11 | NULL | e23850eeb91d4fa3866af634223e454c | shares | 0 | 0 | NULL | 14ff61bc-a3b1-4c3d-9e2e-e5074e01531e |
| 2017-07-26 09:32:26 | 2017-07-26 09:32:37 | NULL | 0 | 12 | NULL | e23850eeb91d4fa3866af634223e454c | gigabytes | 0 | 0 | NULL | 3d1b78e4-d8a1-4fe0-a23c-305ef3ae3275 |
| 2017-07-26 09:32:26 | 2017-07-26 09:32:37 | NULL | 0 | 13 | NULL | e23850eeb91d4fa3866af634223e454c | shares | 0 | 0 | NULL | 3d1b78e4-d8a1-4fe0-a23c-305ef3ae3275 |
+---------------------+---------------------+------------+---------+----+----------------------------------+----------------------------------+----------------+--------+----------+---------------+--------------------------------------+
We got the redundant record with same user_id, same project_id and same share_type_id.
We have two or more ways to fix this bug,
1. We could combine the quota record in db if these quota's user_id, project_id and share_type_id etc at the same when we create a share.
2. The quota reserve and commit model has many problems [1]. We could just remove the quota model in the code.
We could discuss it in PTG or another meeting to decide how to resolve this bug.
[1] https:/ /specs. openstack. org/openstack/ nova-specs/ specs/pike/ approved/ cells-count- resources- to-check- quota-in- api.html