1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
--source include/have_ndb.inc
--source include/have_log_bin.inc
#
#
# This test aims at checking if ndbcluster can adapt to the
# changes made to ndb_log_transaction_compression dynamically during runtime.
#
#
--echo ################################################
--echo Validate binary log transaction compression
--echo option values and ranges
--echo ################################################
--error ER_GLOBAL_VARIABLE
set @@SESSION.ndb_log_transaction_compression = ON;
set @@GLOBAL.ndb_log_transaction_compression = ON;
--error ER_GLOBAL_VARIABLE
set @@SESSION.ndb_log_transaction_compression_level_zstd = 1;
set @@GLOBAL.ndb_log_transaction_compression_level_zstd = 0;
--echo Truncated to 1
show variables like 'ndb_log_transaction_compression_level_zstd';
set @@GLOBAL.ndb_log_transaction_compression_level_zstd = 23;
--echo Truncated to 22
show variables like 'ndb_log_transaction_compression_level_zstd';
set @@GLOBAL.ndb_log_transaction_compression = DEFAULT;
set @@GLOBAL.ndb_log_transaction_compression_level_zstd = DEFAULT;
--echo ################################################
--echo Case 1: Observe binlog compression in ndbcluster
--echo when ndb_log_transaction_compression = default
--echo ################################################
show variables like 'ndb_log_bin';
show variables like 'ndb_log_transaction_compression';
show variables like 'ndb_log_transaction_compression_level_zstd';
# Create and insert rows to the table to check if the data is compressed.
create table t1 (a int) engine=ndb;
insert into t1 values (1);
insert into t1 select a+1 from t1;
insert into t1 select a+2 from t1;
# Check for compressed data in binlog using binary_log_transaction_compression_stats table
# As default for ndb_log_transaction_compression is OFF, there should not be any row with ZSTD compression type
# SELECT LOG_TYPE, COMPRESSION_TYPE, COMPRESSED_BYTES_COUNTER, UNCOMPRESSED_BYTES_COUNTER FROM PERFORMANCE_SCHEMA.binary_log_transaction_compression_stats;
--let $nrows = `SELECT COUNT(*) FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'ZSTD'`
--let $assert_cond = $nrows = 0
--let $assert_text = Number of rows in performance_schema.binary_log_transaction_compression (BINARY, ZSTD) = 0
--source include/assert.inc
--echo ################################################
--echo Case 2: Observe binlog compression in ndbcluster
--echo when ndb_log_transaction_compression = ON
--echo ################################################
# Turn ON ndb_log_transaction_compression to check if the binlog thread can adapt to this change
set global ndb_log_transaction_compression = ON;
show global variables like 'ndb_log_transaction_compression';
insert into t1 select a+4 from t1;
# Wait for epoch
--disable_query_log
--disable_result_log
show binlog events;
--enable_result_log
--enable_query_log
# Check if there are any compressed data in binlog using binary_log_transaction_compression_stats table
# As ndb_log_transaction_compression is ON, there should be atleast one row with ZSTD compression type
# SELECT LOG_TYPE, COMPRESSION_TYPE, COMPRESSED_BYTES_COUNTER, UNCOMPRESSED_BYTES_COUNTER FROM PERFORMANCE_SCHEMA.binary_log_transaction_compression_stats;
--let $nrows = `SELECT COUNT(*) FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'ZSTD'`
--let $assert_cond = $nrows = 1
--let $assert_text = Number of rows in performance_schema.binary_log_transaction_compression (BINARY, ZSTD) = 1
--source include/assert.inc
# Record the current size of data in the binlog.
--let $compressed_data = `SELECT COMPRESSED_BYTES_COUNTER FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'ZSTD'`
--let $uncompressed_data = `SELECT COMPRESSED_BYTES_COUNTER FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'NONE'`
--echo ################################################
--echo Case 3: Observe binlog compression in ndbcluster
--echo when ndb_log_transaction_compression = OFF
--echo ################################################
# Turn OFF ndb_log_transaction_compression to check if the binlog thread can adapt to this change
set global ndb_log_transaction_compression = OFF;
show global variables like 'ndb_log_transaction_compression';
insert into t1 select a+8 from t1;
# Wait for epoch
--disable_query_log
--disable_result_log
show binlog events;
--enable_result_log
--enable_query_log
# SELECT LOG_TYPE, COMPRESSION_TYPE, COMPRESSED_BYTES_COUNTER, UNCOMPRESSED_BYTES_COUNTER FROM PERFORMANCE_SCHEMA.binary_log_transaction_compression_stats;
--let $new_compressed_data = `SELECT COMPRESSED_BYTES_COUNTER FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'ZSTD'`
--let $assert_cond = $new_compressed_data = $compressed_data
--let $assert_text = Compressed data size remains same.
--source include/assert.inc
--let $new_uncompressed_data = `SELECT COMPRESSED_BYTES_COUNTER FROM performance_schema.binary_log_transaction_compression_stats WHERE log_type = 'BINARY' AND COMPRESSION_TYPE = 'NONE'`
--let $assert_cond = $new_uncompressed_data > $uncompressed_data
--let $assert_text = Uncompressed data size increased.
--source include/assert.inc
# Cleanup
TRUNCATE performance_schema.binary_log_transaction_compression_stats;
drop table t1;
|