Bug #116504 Insert into punch hole compression table drop of zero randomly
Submitted: 30 Oct 12:52 Modified: 7 Nov 15:14
Reporter: zkong kong Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0 OS:Linux
Assigned to: CPU Architecture:Any

[30 Oct 12:52] zkong kong
Description:
After simply fix the issue:
https://bugs.mysql.com/bug.php?id=116501

iff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index e0951f2e1e1..566af8c41b9 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -1884,7 +1884,7 @@ file::Block *os_file_compress_page(IORequest &type, void *&buf, ulint *n) {
   byte *compressed_page;
 
   compressed_page =
-      static_cast<byte *>(ut_align(block->m_ptr, UNIV_SECTOR_SIZE));
+      static_cast<byte *>(ut_align(block->m_ptr, 4096));
 
   byte *buf_ptr;

Run sysbench and the insert may drop of zero randomly:

[ 2714s ] thds: 128 tps: 57678.30 qps: 57679.30 (r/w/o: 0.00/57679.30/0.00) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
[ 2715s ] thds: 128 tps: 65678.98 qps: 65677.98 (r/w/o: 0.00/65677.98/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2716s ] thds: 128 tps: 74975.68 qps: 74975.68 (r/w/o: 0.00/74975.68/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2717s ] thds: 128 tps: 58526.65 qps: 58526.65 (r/w/o: 0.00/58526.65/0.00) lat (ms,95%): 2.30 err/s: 0.00 reconn/s: 0.00
[ 2718s ] thds: 128 tps: 56166.21 qps: 56166.21 (r/w/o: 0.00/56166.21/0.00) lat (ms,95%): 2.57 err/s: 0.00 reconn/s: 0.00
[ 2719s ] thds: 128 tps: 72519.75 qps: 72519.75 (r/w/o: 0.00/72519.75/0.00) lat (ms,95%): 2.43 err/s: 0.00 reconn/s: 0.00
[ 2720s ] thds: 128 tps: 71096.04 qps: 71096.04 (r/w/o: 0.00/71096.04/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2721s ] thds: 128 tps: 56114.60 qps: 56114.60 (r/w/o: 0.00/56114.60/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2722s ] thds: 128 tps: 547.02 qps: 547.02 (r/w/o: 0.00/547.02/0.00) lat (ms,95%): 303.33 err/s: 0.00 reconn/s: 0.00
[ 2723s ] thds: 128 tps: 39355.45 qps: 39355.45 (r/w/o: 0.00/39355.45/0.00) lat (ms,95%): 2.66 err/s: 0.00 reconn/s: 0.00
[ 2724s ] thds: 128 tps: 67812.33 qps: 67812.33 (r/w/o: 0.00/67812.33/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2725s ] thds: 128 tps: 46245.97 qps: 46245.97 (r/w/o: 0.00/46245.97/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2726s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2727s ] thds: 128 tps: 63491.39 qps: 63491.39 (r/w/o: 0.00/63491.39/0.00) lat (ms,95%): 2.43 err/s: 0.00 reconn/s: 0.00
[ 2728s ] thds: 128 tps: 9944.91 qps: 9944.91 (r/w/o: 0.00/9944.91/0.00) lat (ms,95%): 2.43 err/s: 0.00 reconn/s: 0.00
[ 2729s ] thds: 128 tps: 73524.73 qps: 73524.73 (r/w/o: 0.00/73524.73/0.00) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
[ 2730s ] thds: 128 tps: 69997.57 qps: 69997.57 (r/w/o: 0.00/69997.57/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2731s ] thds: 128 tps: 18822.09 qps: 18822.09 (r/w/o: 0.00/18822.09/0.00) lat (ms,95%): 2.26 err/s: 0.00 reconn/s: 0.00
[ 2732s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2733s ] thds: 128 tps: 1040.99 qps: 1040.99 (r/w/o: 0.00/1040.99/0.00) lat (ms,95%): 2828.87 err/s: 0.00 reconn/s: 0.00
[ 2734s ] thds: 128 tps: 58178.72 qps: 58178.72 (r/w/o: 0.00/58178.72/0.00) lat (ms,95%): 2.43 err/s: 0.00 reconn/s: 0.00
[ 2735s ] thds: 128 tps: 73683.04 qps: 73683.04 (r/w/o: 0.00/73683.04/0.00) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
[ 2736s ] thds: 128 tps: 21027.60 qps: 21027.60 (r/w/o: 0.00/21027.60/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2737s ] thds: 128 tps: 13624.61 qps: 13624.61 (r/w/o: 0.00/13624.61/0.00) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
[ 2738s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2739s ] thds: 128 tps: 17247.10 qps: 17247.10 (r/w/o: 0.00/17247.10/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2740s ] thds: 128 tps: 5106.98 qps: 5106.98 (r/w/o: 0.00/5106.98/0.00) lat (ms,95%): 1.82 err/s: 0.00 reconn/s: 0.00
[ 2741s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2742s ] thds: 128 tps: 23881.37 qps: 23881.37 (r/w/o: 0.00/23881.37/0.00) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
[ 2743s ] thds: 128 tps: 43452.85 qps: 43452.85 (r/w/o: 0.00/43452.85/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2744s ] thds: 128 tps: 57553.42 qps: 57553.42 (r/w/o: 0.00/57553.42/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2745s ] thds: 128 tps: 9569.68 qps: 9569.68 (r/w/o: 0.00/9569.68/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2746s ] thds: 128 tps: 13785.15 qps: 13785.15 (r/w/o: 0.00/13785.15/0.00) lat (ms,95%): 1.86 err/s: 0.00 reconn/s: 0.00
[ 2747s ] thds: 128 tps: 23055.71 qps: 23055.71 (r/w/o: 0.00/23055.71/0.00) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
[ 2748s ] thds: 128 tps: 15749.44 qps: 15749.44 (r/w/o: 0.00/15749.44/0.00) lat (ms,95%): 1.73 err/s: 0.00 reconn/s: 0.00
[ 2749s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2750s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2751s ] thds: 128 tps: 9439.64 qps: 9439.64 (r/w/o: 0.00/9439.64/0.00) lat (ms,95%): 2.07 err/s: 0.00 reconn/s: 0.00
[ 2752s ] thds: 128 tps: 65.00 qps: 65.00 (r/w/o: 0.00/65.00/0.00) lat (ms,95%): 0.48 err/s: 0.00 reconn/s: 0.00
[ 2753s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2754s ] thds: 128 tps: 8361.83 qps: 8361.83 (r/w/o: 0.00/8361.83/0.00) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
[ 2755s ] thds: 128 tps: 22186.80 qps: 22186.80 (r/w/o: 0.00/22186.80/0.00) lat (ms,95%): 2.48 err/s: 0.00 reconn/s: 0.00
[ 2756s ] thds: 128 tps: 49382.54 qps: 49382.54 (r/w/o: 0.00/49382.54/0.00) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
[ 2757s ] thds: 128 tps: 3642.98 qps: 3642.98 (r/w/o: 0.00/3642.98/0.00) lat (ms,95%): 0.90 err/s: 0.00 reconn/s: 0.00
[ 2758s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2759s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00
[ 2760s ] thds: 128 tps: 30017.19 qps: 30017.19 (r/w/o: 0.00/30017.19/0.00) lat (ms,95%): 2.35 err/s: 0.00 reconn/s: 0.00
[ 2761s ] thds: 128 tps: 65721.36 qps: 65721.36 (r/w/o: 0.00/65721.36/0.00) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
[ 2762s ] thds: 128 tps: 0.00 qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 0.00 err/s: 0.00 reconn/s: 0.00

/dev/md0p1       50G   43G  7.4G  86% /data1 
The space not used up but the fragment is very high

[root@TENCENT64 ~]# xfs_db -r -c "freesp" /dev/md0p1
   from      to extents  blocks    pct
      1       1 1936675 1936675 100.00
      2       3       3       9   0.00

How to repeat:
Run compression sysbench:

/data1/ragnar/tools/sysbench/bin/sysbench /data1/ragnar/tools/sysbench/share/sysbench/oltp_insert.lua --mysql-host=9.30.5.83 --mysql-port=4306 --mysql-db=sysbench --tables=128 --table-size=10000 --mysql-user=test1234 --mysql-password=test1234 --threads=128 --report-interval=1 --time=360000 --create-table-options=compression='zlib' run
[30 Oct 14:53] MySQL Verification Team
HI Mr. kong,

First of all, thank you for the patch that you provided, but we cannot know whether this is a proper patch.

Hence, we first have to verify bug #116501 and then ask our Development for the validity of that patch.

Only after our Development confirms the patch, can we proceed to test this bug report.

Meanwhile, can you run some profiling software that might show up the cause of this drop in the performance. A drop can be due to filesystem marking the patch holes or due to the inadequate CPU for the task ahead.

We are waiting on your feedback.
[31 Oct 3:00] zkong kong
Hi:
  top - 10:57:32 up 9 days, 20:37,  9 users,  load average: 0.56, 3.28, 3.78
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.4 us,  0.6 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 52723532+total, 43595308+free, 16191848 used, 75090392 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 50741033+avail Mem 
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                                              47112 tdsql     20   0   16.9g  12.9g  44868 S   0.3  2.6   1052:16 mysqld

mysql> show processlist;
+-----+-----------------+-------------------+----------+---------+-------+----------------------------+------------------------------------------------------------------------------------------------------+
| Id  | User            | Host              | db       | Command | Time  | State                      | Info                                                                                                 |
+-----+-----------------+-------------------+----------+---------+-------+----------------------------+------------------------------------------------------------------------------------------------------+
|   5 | event_scheduler | localhost         | NULL     | Daemon  | 54770 | Waiting on empty queue     | NULL                                                                                                 |
| 397 | tdsqlsys_agent  | localhost         | NULL     | Query   |     0 | init                       | show processlist                                                                                     |
| 526 | test1234        | 9.30.17.135:40124 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest72 (id, k, c, pad) VALUES (0, 2358, '43954627712-41753091291-62232849451-857949267 |
| 527 | test1234        | 9.30.17.135:40128 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest13 (id, k, c, pad) VALUES (0, 6622, '69443182065-82589449222-04348112936-940531681 |
| 528 | test1234        | 9.30.17.135:40136 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest51 (id, k, c, pad) VALUES (0, 4178, '63676682373-09364614543-84358472056-816641077 |
| 529 | test1234        | 9.30.17.135:40134 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest11 (id, k, c, pad) VALUES (0, 7765, '97673673793-04619867116-67935944631-791213777 |
| 530 | test1234        | 9.30.17.135:40126 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest68 (id, k, c, pad) VALUES (0, 6665, '52916858941-47309246954-34853296044-871112443 |
| 531 | test1234        | 9.30.17.135:40132 | sysbench | Query   |   181 | waiting for handler commit | INSERT INTO sbtest32 (id, k, c, pad) VALUES (0, 2240, '87502478956-52870056959-16168407819-328762630 |
....

130 rows in set, 1 warning (0.00 sec)

[root@TENCENT64 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        252G     0  252G   0% /dev
tmpfs           252G   20M  252G   1% /dev/shm
tmpfs           252G  260M  252G   1% /run
tmpfs           252G     0  252G   0% /sys/fs/cgroup
/dev/sda1        20G   17G  1.7G  92% /
/dev/sda2       511M  7.0M  505M   2% /boot/efi
/dev/sda3        20G  2.2G   17G  12% /usr/local
/dev/sda4       4.9T  549G  4.1T  12% /data
tmpfs            51G     0   51G   0% /run/user/6666
tmpfs            51G     0   51G   0% /run/user/6667
tmpfs            51G     0   51G   0% /run/user/0
/dev/md0p1       50G   28G   23G  55% /data1
/dev/md0p2       50G   33M   50G   1% /data2
/dev/md0p3      100G  100G   24K 100% /data3
/dev/md0p4      6.4T  7.1G  6.4T   1% /data4
[root@TENCENT64 ~]# du -s -h /data1
28G     /data1
[31 Oct 3:36] zkong kong
The perf data

Samples: 693K of event 'cpu-clock', Event count (approx.): 173415500000
  Overhead  Command          Shared Object                              Symbol                                                                                                                                                                                                     ◆
+    4.43%  connection       [kernel.vmlinux]                           [k] _raw_spin_lock                                                                                                                                                                                         ▒
+    2.65%  connection       [kernel.vmlinux]                           [k] _raw_spin_unlock_irqrestore                                                                                                                                                                            ▒
-    2.56%  connection       [xfs]                                      [k] xfs_alloc_get_rec                                                                                                                                                                                      ▒
   - xfs_alloc_get_rec                                                                                                                                                                                                                                                             ▒
      - 2.35% xfs_alloc_ag_vextent_size                                                                                                                                                                                                                                            ▒
           xfs_alloc_ag_vextent                                                                                                                                                                                                                                                    ▒
           xfs_alloc_vextent                                                                                                                                                                                                                                                       ▒
           xfs_bmap_btalloc                                                                                                                                                                                                                                                        ▒
           xfs_bmap_alloc                                                                                                                                                                                                                                                          ▒
           xfs_bmapi_write                                                                                                                                                                                                                                                         ▒
           xfs_alloc_file_space                                                                                                                                                                                                                                                    ▒
           xfs_file_fallocate                                                                                                                                                                                                                                                      ▒
           vfs_fallocate                                                                                                                                                                                                                                                           ▒
           sys_fallocate                                                                                                                                                                                                                                                           ▒
           do_syscall_64                                                                                                                                                                                                                                                           ▒
           entry_SYSCALL_64                                                                                                                                                                                                                                                        ▒
           posix_fallocate64                                                                                                                                                                                                                                                       ▒
           fsp_try_extend_data_file                                                                                                                                                                                                                                                ▒
           fsp_reserve_free_extents                                                                                                                                                                                                                                                ▒
         + btr_cur_pessimistic_insert
[31 Oct 3:43] zkong kong
Hi:
  It's only occur when the xfs fragment is very high

[root@TENCENT64 /data3/log/4306/dblogs/bin]# xfs_db -r -c "freesp" /dev/md0p1
Metadata CRC error detected at xfs_allocbt block 0x1efe698/0x1000
Metadata CRC error detected at xfs_allocbt block 0x44bd440/0x1000
Metadata CRC error detected at xfs_allocbt block 0x4b34d58/0x1000
   from      to extents  blocks    pct
      1       1  951858  951858  99.96
      2       3     177     413   0.04
[31 Oct 11:10] MySQL Verification Team
Hi Mr. kong,

Waiting on the Linux box to be prepared for this bug ......
[7 Nov 15:14] MySQL Verification Team
Hi Mr. kong,

This bug is now verified, since but 116501 turned out to be true.

This is now a verified bug for versions 8.0, 8.4, 9.0 and 9.1.

Thank you.