[MDEV-13497] concurrently used sequence hangs in SEQUENCE::next_value Created: 2017-08-10 Updated: 2017-08-17 Resolved: 2017-08-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Sequences |
| Affects Version/s: | 10.3.0 |
| Fix Version/s: | 10.3.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Axel Schwenke | Assignee: | Axel Schwenke |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
A workload where many workers concurrently pull a number from a InnoDB sequence and insert the number into another InnoDB table using transactions, occasionally causes all worker threads to hang in SEQUENCE::next_value. Everything is fine when no transactions are used (autocommit) or when the sequence object is using the MyISAM engine. How to repeat: You need Lua-enabled sysbench, i.e. from https://github.com/hgxl64/sysbench-mariadb.git. Then use the attached test script sequence_native.lua:
You might need to alter the sequence cache size or number of threads. The Lua script understands a few options: My guess is, that something goes wrong if the sequence cache runs empty for multiple worker threads and they have to dive for the base table at the same time. The bigger the sequence cache is, the more worker threads are needed to trigger the hang. I.e. with Cache=1000 I need 16 threads. Attached is also my.cnf and a stack trace from a hanging mysqld. |
| Comments |
| Comment by Marko Mäkelä [ 2017-08-15 ] | ||||||||||||||||||||||||||||||||||||
|
This looks like an InnoDB bug. From the hang.trace.txt.gz
There should be no InnoDB table or record locking for the SEQUENCE pseudo-table. | ||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
I implemented the InnoDB part of SEQUENCE in Because the test did not involve restarting the server, we can rule out this bug: The stack trace indicates that InnoDB wrongly tried to acquire a transactional lock on a sequence. Sequences are not supposed to use any transactions or transactional locks. They are being persisted via the InnoDB redo log. Concurrency control inside InnoDB is supposed to rely solely on the buf_page_t::lock on the page that stores the state of the sequence. The sequence is internally maintained in a 1-page, 1-record clustered index that is updated-in-place. I believe that this bug was fixed in this MDEV-10139 follow-up commit that includes the following change:
| ||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
axel, please confirm if this bug is repeatable with
and fixed in
If this is the case, please close the bug as fixed in 10.3.1, because that fix is present in 10.3.1. | ||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-17 ] | ||||||||||||||||||||||||||||||||||||
|
I confirmed that the bug was fixed by commit 8acf4d6f783e5a5f736624064989b88867143685. I can immediately reproduce the hang with the parent of that commit, and not with that commit. |