|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# This test will make many transactions to be grouped when binary logged |
| 4 | +# and will assert that they used the lock_sidno less times than the amount |
| 5 | +# of transactions * 2. |
| 6 | +# |
| 7 | +# Previous to BUG#24398760 fix, every transaction being committed would |
| 8 | +# take the lock_sidno twice inside ordered_commit function: |
| 9 | +# a) At the flush stage, to be assigned with a new GTID and take the ownership |
| 10 | +# of the GTID; |
| 11 | +# b) At the commit stage, to release the ownership of the GTID and to add the |
| 12 | +# gtid to the GTID_EXECUTED set. |
| 13 | +# |
| 14 | +# So, a group committing 10 transactions would take the sidno_lock 20 times. |
| 15 | +# |
| 16 | +# According to the bug report, having about 300 threads committing small |
| 17 | +# transactions would lead to groups of up to 90 transactions on high performance |
| 18 | +# environments. This would mean that the system would have about 180 threads |
| 19 | +# trying to lock the sidno_lock (90 at the flush stage, 90 at the commit stage). |
| 20 | +# |
| 21 | +# Even knowing that the threads would acquire the lock one by one at each stage, |
| 22 | +# this might generate unnecessary overhead when the system is loaded. |
| 23 | +# |
| 24 | +# As the bug fix makes a group of transactions to acquire the sidno_lock only |
| 25 | +# once at the commit stage, this test case will create a group of 10 |
| 26 | +# transactions to commit and will observe the performance schema data about the |
| 27 | +# sidno_lock, asserting that the amount of "hits" on COUNT_STAR is 11 |
| 28 | +# (1 per transaction on FLUSH stage + 1 for the whole group on COMMIT stage). |
| 29 | +# |
| 30 | +# ==== Related Bugs and Worklogs ==== |
| 31 | +# |
| 32 | +# BUG#24398760 GTIDS REDUCE PERFORMANCE ON WORKLOADS WITH MANY SMALL |
| 33 | +# TRANSACTIONS |
| 34 | +# |
| 35 | + |
| 36 | +# This test case is binary log format agnostic |
| 37 | +--source include/have_binlog_format_mixed.inc |
| 38 | +--source include/have_binlog_order_commits.test |
| 39 | +--source include/have_perfschema.inc |
| 40 | +--source include/have_debug_sync.inc |
| 41 | +--source include/have_gtid.inc |
| 42 | +# The amount of transactions that will be part of the commit group |
| 43 | +--let $group_size= 10 |
| 44 | +--let $rpl_extra_connections_per_server= $group_size |
| 45 | +--source include/master-slave.inc |
| 46 | + |
| 47 | +--let $sync_point_timeout= 100 |
| 48 | + |
| 49 | +CREATE TABLE t1 (a INT); |
| 50 | + |
| 51 | +# Cleanup performance schema table about locks |
| 52 | +TRUNCATE performance_schema.events_waits_summary_by_instance; |
| 53 | + |
| 54 | +# Execute the transactions up to the FLUSH stage |
| 55 | +--let $i= 1 |
| 56 | +while ($i <= $group_size) |
| 57 | +{ |
| 58 | + --let $statement_connection= server_1_$i |
| 59 | + --let $sync_point= bgc_after_enrolling_for_flush_stage |
| 60 | + --let $statement= INSERT INTO t1 VALUES ($i) |
| 61 | + --let $auxiliary_connection= master |
| 62 | + --source include/execute_to_sync_point.inc |
| 63 | + |
| 64 | + --inc $i |
| 65 | +} |
| 66 | + |
| 67 | +# Let the transactions to execute from the FLUSH stage |
| 68 | +--let $skip_reap= 1 |
| 69 | + |
| 70 | +--let $i= 1 |
| 71 | +while ($i <= $group_size) |
| 72 | +{ |
| 73 | + --let $statement_connection= server_1_$i |
| 74 | + --let $sync_point= bgc_after_enrolling_for_flush_stage |
| 75 | + --let $statement= INSERT INTO t1 VALUES ($i) |
| 76 | + --let $auxiliary_connection= master |
| 77 | + --source include/execute_from_sync_point.inc |
| 78 | + |
| 79 | + --inc $i |
| 80 | +} |
| 81 | + |
| 82 | +# Reap all the transactions |
| 83 | +--let $i= 1 |
| 84 | +while ($i <= $group_size) |
| 85 | +{ |
| 86 | + --let $rpl_connection_name= server_1_$i |
| 87 | + --source include/rpl_connection.inc |
| 88 | + --reap |
| 89 | + |
| 90 | + --inc $i |
| 91 | +} |
| 92 | + |
| 93 | +# There will be one "hit" per transaction on FLUSH stage |
| 94 | +--let $sidno_lock_count_star= $group_size |
| 95 | +# There will be one "hit" per commit group on COMMIT stage |
| 96 | +--inc $sidno_lock_count_star |
| 97 | + |
| 98 | +--let $assert_text= The group commit should acquire sidno_lock for $sidno_lock_count_star times |
| 99 | +--let $assert_cond= [ SELECT COUNT_STAR = $sidno_lock_count_star FROM performance_schema.events_waits_summary_by_instance WHERE EVENT_NAME = "wait/synch/mutex/sql/Gtid_state" AND COUNT_STAR > 0 ] |
| 100 | +--source include/assert.inc |
| 101 | + |
| 102 | +# Cleanup |
| 103 | +DROP TABLE t1; |
| 104 | +--source include/rpl_end.inc |
0 commit comments