[MDEV-28518] After update to 10.5 a lot of time is spent in "Sending data" Created: 2022-05-09 Updated: 2023-01-12 Resolved: 2022-10-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.5.10, 10.5.15 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sander Hoentjen | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 4 |
| Labels: | optimizer, performance, regression | ||
| Environment: |
CloudLinux release 8.5 |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Since updating to 10.5, sometimes performance collapses. Queries that normally take less then a second, can take multiple minutes. The time is spent in state "Sending data"
This this on a shared database of a hosting company, with many concurrent accesses. After restarting MariaDB things are a bit better for a while, but not as good as it was with 10.4 Apart from this, we also see that (some) queries spend a lot more time in "Statistics" state than they used to. If I can provide any more information, please let me know! |
| Comments |
| Comment by Sander Hoentjen [ 2022-05-10 ] | |||||||||||||||||||||||||||||||||||
|
In the logs we see multiple occurences of Where dbname and table name can differ Also, most queries are in "Statistics" state now
| |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2022-05-10 ] | |||||||||||||||||||||||||||||||||||
|
"Sending data" is a poor name for "Running the join operation and sending result to output" . (Inherited from the time when most of the queries were really basic). It would be helpful if we had ANALYZE FORMAT=JSON output for a "fast" query run and a "slow" run of the same query. | |||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2022-05-10 ] | |||||||||||||||||||||||||||||||||||
|
Re-formatted the query:
The optimizer can pick multiple join orders for it (either lm_posts, lm_postmeta or lm_postmeta,lm_posts. | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-20 ] | |||||||||||||||||||||||||||||||||||
|
Because the situation was awful for our customers, we moved away some of them to reduce the load. The situation is much better now, it seems there is some tipping point where if you move past that, things fall all over each other. While the situation is better, it is still worse than with 10.4. But, since it is better, it is harder to reproduce and run tests. I will keep trying to get relevant data. | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-24 ] | |||||||||||||||||||||||||||||||||||
|
With the help of the plugin author of mysites.guru we found a query that performs extremely bad on MariaDB 10.5+. I attached the reproducers here db.sql.bz2 On the system we tested, with 10.4, running largeSQL.sql on the db created with db.sql.bz2 takes about 0.2s, whereas with 10.5 it takes more than 30s! Of course I don't know if this is all related, but I have good hope that if this is fixed, overall performance will improve as well. | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-25 ] | |||||||||||||||||||||||||||||||||||
|
Git bisect shows c36720388d598ca3aa1c4d2dab2266656c528b50 is the offending commit. Versions before complete the above in 200ms, after that it takes 30s+ | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-26 ] | |||||||||||||||||||||||||||||||||||
|
Setting optimizer_max_sel_arg_weight to a low value helps performance for this query | |||||||||||||||||||||||||||||||||||
| Comment by Ludovic Monnier [ 2022-05-30 ] | |||||||||||||||||||||||||||||||||||
|
We observed the same issue since Maria 10.5 using a SELECT ... FROM... GROUP BY.... syntax Very poor performance using mariadb 10.5 and after !! I check the same request with same data using few version of mariadb : #Version: 10.3.34-MariaDB-0+deb10u1-log (Debian 10). Query_time: 724.197647 Lock_time: 0.037806 Rows_sent: 0 Rows_examined: 82160658 Query_time: 564.029273 Lock_time: 0.044647 Rows_sent: 0 Rows_examined: 82160658 Query_time: 546.300378 Lock_time: 0.123554 Rows_sent: 0 Rows_examined: 82160658 Query_time: 2116.641373 Lock_time: 0.024204 Rows_sent: 0 Rows_examined: 82160658 | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-30 ] | |||||||||||||||||||||||||||||||||||
|
Can you confirm that if you do:
before the query, that performance is okay with 10.5? | |||||||||||||||||||||||||||||||||||
| Comment by Ludovic Monnier [ 2022-05-30 ] | |||||||||||||||||||||||||||||||||||
|
Hi, I tried it. But performance are always poor using mariadb 10.5.16.
VS mariadb 10.3.34:
During request, we can observe a large MAI create using 10.5.16. (With 10.3 or 10.4 the MAI file don't exceed 2M) [15:32:58] # ls -rtlh /mnt/mysqldata/tmp/ [15:36:14] root@sfr-bdprod-5-restore:~# ls -rtlh /mnt/mysqldata/tmp/ [15:36:23] # ls -rtlh /mnt/mysqldata/tmp/ [15:38:04] # ls -rtlh /mnt/mysqldata/tmp/ [15:47:40] # ls -rtlh /mnt/mysqldata/tmp/ | |||||||||||||||||||||||||||||||||||
| Comment by Sander Hoentjen [ 2022-05-30 ] | |||||||||||||||||||||||||||||||||||
|
@Ludovic Monnier Then I don't think this is the same underlying issue. | |||||||||||||||||||||||||||||||||||
| Comment by Ludovic Monnier [ 2022-05-30 ] | |||||||||||||||||||||||||||||||||||
|
Perhaps is not the same issue. but query time is x 4 between mariadb 10.4 and 10.5 I add the SHOW PROFILE FOR QUERY
'Starting', 0.000006 | |||||||||||||||||||||||||||||||||||
| Comment by Joris de Leeuw [ 2022-09-22 ] | |||||||||||||||||||||||||||||||||||
|
This issue seems to be fixed with | |||||||||||||||||||||||||||||||||||
| Comment by Joris de Leeuw [ 2022-10-12 ] | |||||||||||||||||||||||||||||||||||
|
This issue can be closed. The example shared by my colleague Sander Hoentjen has very positive differences between 10.6.16 and 10.5.17. After updating production servers from 10.5.16 to 10.5.17 we don't see queries stuck in "Statistics" state as before. Also we see less crashes with MariaDB 10.5.17 than with MariaDB 10.4.x and 10.5.16--. We however see still rarely that MariaDB 10.5.x gets stuck in an 'too many connections' state without any clear cause. This seems a separate issue that we are still investigating. |