-
Notifications
You must be signed in to change notification settings - Fork 1.3k
engine/schema: force index in user_vm_view to speed up instance listing #9198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sting The user_vm_view can end up not picking the right index to join against the user_ip_address table causing full table scan on the user_ip_address table. This could be related to a MySQL bug https://bugs.mysql.com/bug.php?id=41220 In a test environment with 20k shared networks and over 20M IPs, the listVirtualMachines API was found to take over 17s to return list of just 10 VMs. However, with this fix it would now take under 200ms to return the list. MySQL slow query logging showed ~nearly 20M table scans of the IP address table: ``` SET timestamp=1715410270; SELECT user_vm_view.id, user_vm_view.name /*snipped*/ FROM user_vm_view WHERE user_vm_view.id IN (4,6,7,8,9,10,11,12,13,14,15,16); ``` Signed-off-by: Rohit Yadav <[email protected]>
shwstppr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm
|
@blueorangutan package |
|
@rohityadavcloud a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 4.19 #9198 +/- ##
============================================
- Coverage 14.96% 4.30% -10.66%
============================================
Files 5373 363 -5010
Lines 469248 29302 -439946
Branches 58782 5116 -53666
============================================
- Hits 70210 1261 -68949
+ Misses 391266 27898 -363368
+ Partials 7772 143 -7629
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
weizhouapache
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code lgtm
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9841 |
|
@blueorangutan test |
|
@rohityadavcloud a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-10407)
|
DaanHoogland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
|
Tested locally on a 4.19/KVM env homelab with 3 hosts and less than 20 user VMs (across accounts & projects), with this changes my own listing of 10 VMs reduces from about 1s to under 50ms. |
|
cc @NuxRo - if you have any insights from a production env (user/customer)? Thanks. |
|
Tested this on a 4.18 and 4.19 env; with large number of simulator hosts and networks in one env; and in case of my KVM-based homelab with MySQL 8.0.36 on Ubuntu 22.04. After the view/change was applied, this is the explain analyze: For comparison, when the index is used the number of actual rows that could have been scanned reduces dramatically: |
…sting (apache#9198) The user_vm_view can end up not picking the right index to join against the user_ip_address table causing full table scan on the user_ip_address table. This could be related to a MySQL bug https://bugs.mysql.com/bug.php?id=41220 In a test environment with 20k shared networks and over 20M IPs, the listVirtualMachines API was found to take over 17s to return list of just 10 VMs. However, with this fix it would now take under 200ms to return the list. MySQL slow query logging showed ~nearly 20M table scans of the IP address table: ``` # User@Host: cloud[cloud] @ localhost [127.0.0.1] Id: 39 # Query_time: 8.227541 Lock_time: 0.000014 Rows_sent: 12 Rows_examined: 19,667,235 SET timestamp=1715410270; SELECT user_vm_view.id, user_vm_view.name /*snipped*/ FROM user_vm_view WHERE user_vm_view.id IN (4,6,7,8,9,10,11,12,13,14,15,16); ``` Signed-off-by: Rohit Yadav <[email protected]>
The user_vm_view can end up not picking the right index to join against the user_ip_address table causing full table scan on the user_ip_address table. This could be related to a MySQL bug
https://bugs.mysql.com/bug.php?id=41220
In a test environment with 20k shared networks and over 20M IPs, the listVirtualMachines API was found to take over 17s to return list of just 10 VMs. However, with this fix it would now take under 200ms to return the list. (MySQL Server: 8.0.36)
MySQL slow query logging showed ~nearly 20M table scans of the IP address table:
Visual explain:

This may not be worse than what it already is, I'm open to more ideas and suggestions.
Addresses #7910
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity