| 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 flush stage and only once at the commit stage, this test case will |
| 26 |
# create a group of 10 transactions to commit and will observe the performance |
| 27 |
# schema data about the sidno_lock, asserting that the amount of "hits" on |
| 28 |
# COUNT_STAR is 2: |
| 29 |
# - 1 for the whole group on FLUSH stage; |
| 30 |
# - 1 for the whole group on COMMIT stage. |
| 31 |
# |
| 32 |
# ==== Related Bugs and Worklogs ==== |
| 33 |
# |
| 34 |
# BUG#24398760 GTIDS REDUCE PERFORMANCE ON WORKLOADS WITH MANY SMALL |
| 35 |
# TRANSACTIONS |
| 36 |
# |
| 37 |
|
| 38 |
# This test case is binary log format agnostic |
| 39 |
--source include/have_binlog_format_mixed.inc |
| 40 |
--source include/have_binlog_order_commits.test |
| 41 |
--source include/have_debug_sync.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= 1 |
| 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 |
--let $extra_debug_info= Current COUNT_STAR for wait/synch/mutex/sql/Gtid_state |
| 101 |
--let $extra_debug_eval= COUNT_STAR FROM performance_schema.events_waits_summary_by_instance WHERE EVENT_NAME = "wait/synch/mutex/sql/Gtid_state" AND COUNT_STAR > 0 |
| 102 |
--source include/assert.inc |
| 103 |
|
| 104 |
# Cleanup |
| 105 |
DROP TABLE t1; |
| 106 |
--source include/rpl_end.inc |