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