Uploaded image for project: 'Percona Toolkit'
  1. Percona Toolkit
  2. PT-2127

pt-archiver does not archive tables with binary data columns and --bulk-insert option well

Details

    • Bug
    • Status: Confirmation
    • High
    • Resolution: Unresolved
    • None
    • None
    • None
    • None
      • Version:

      pt-archiver Version: 3.4.0
      Mariadb Version: 10.6.11
      Kernel Release: 3.10.0-1160.66.1.el7.x86_64

    • Yes
    • Yes

    Description

      • Description:

      pt-archiver has issues when archiving table with binary data columns and --bulk-insert option.
      Archiving changes some values so that the checksum of the source and destination tables does not give the same values.
      By archiving without the --bulk-insert option, the data in the destination table is the same as in the source table,
      and the checksum of both tables gives the same value.

      • How to reproduce:

      create database testdb;
      use testdb;

      DELIMITER $$
      CREATE DEFINER=`root`@`%` FUNCTION `uuidfrombin`(b BINARY(16)) RETURNS char(36) CHARSET latin1
      DETERMINISTIC
      BEGIN
      DECLARE hex CHAR(32);
      SET hex = HEX(b);
      RETURN LOWER(CONCAT(LEFT(hex, 8), '', MID(hex, 9,4), '', MID(hex, 13,4), '', MID(hex, 17,4), '', RIGHT(hex, 12)));
      END$$
      DELIMITER ;

      DELIMITER $$
      CREATE DEFINER=`root`@`%` FUNCTION `uuidtobin`(s CHAR(36)) RETURNS binary(16)
      DETERMINISTIC
      RETURN UNHEX(CONCAT(LEFT(s, 8), MID(s, 10, 4), MID(s, 15, 4), MID(s, 20, 4), RIGHT(s, 12)))$$
      DELIMITER ;

      CREATE TABLE test (
      id binary(16) NOT NULL,
      bin2 binary(16) DEFAULT NULL,
      bin3 binary(16) DEFAULT NULL,
      namevarchar(25),
      PRIMARYKEY (id)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

      insert into test (id, bin2, bin3, name) VALUES
      (uuidtobin('000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5'), uuidtobin('000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5'), uuidtobin('610025a5-71a6-4fde-a847-cf8612c2bccc'), 'test1'),
      (uuidtobin('0013c64f-4e33-4686-b068-7fc4a8de4441'), uuidtobin('0013c64f-4e33-4686-b068-7fc4a8de4441'), uuidtobin('1ede04fe-ffd0-4bf5-aaa6-572b7bbb9c5a'), 'test2'),
      (uuidtobin('0016274e-7898-4a39-9afb-5b4862a8f9c8'), uuidtobin('0016274e-7898-4a39-9afb-5b4862a8f9c8'), uuidtobin('e28fbe3b-64eb-414e-b676-194286e0c265'), 'test3'),
      (uuidtobin('003dfde9-766d-4368-9b6c-e74acccfffbb'), uuidtobin('003dfde9-766d-4368-9b6c-e74acccfffbb'), uuidtobin('0dd90d22-0c86-4774-b167-4aef082e09af'), 'test4'),
      (uuidtobin('0051c6f8-e09d-44fa-9f26-ebbd8bbb0300'), uuidtobin('0051c6f8-e09d-44fa-9f26-ebbd8bbb0300'), uuidtobin('ea76a8e4-3f10-4711-83de-a999434e2a28'), 'test5'),
      (uuidtobin('005dadfd-1370-4b8c-b17e-0b37905b3418'), uuidtobin('005dadfd-1370-4b8c-b17e-0b37905b3418'), uuidtobin('0fba7404-cfb1-4ad9-bb9c-b2361c50566d'), 'test6'),
      (uuidtobin('00b19468-4f84-49a7-b512-c033eb3ba6ee'), null, uuidtobin('6a084fc5-b4d8-4b38-817a-f593755adf05'), 'test7'),
      (uuidtobin('00c3948d-1212-40ff-8026-0c84c34bd236'), uuidtobin('00c3948d-1212-40ff-8026-0c84c34bd236'), uuidtobin('7a996b78-1996-4ad2-9c11-b597fdb4aaa0'), 'test8'),
      (uuidtobin('00d51819-8494-4d6c-a9e9-0fe725750a22'), uuidtobin('00d51819-8494-4d6c-a9e9-0fe725750a22'), uuidtobin('6f83685f-4451-49bd-b464-ac4c508c2403'), 'test9'),
      (uuidtobin('00f04079-f1a5-43b0-bf40-ea68bc4bd947'), uuidtobin('00f04079-f1a5-43b0-bf40-ea68bc4bd947'), uuidtobin('2f0f016a-caae-48e8-8490-67c8f09c4f23'), 'test91'),
      (uuidtobin('01016c63-3a81-4969-b4b0-a83a463b0686'), uuidtobin('01016c63-3a81-4969-b4b0-a83a463b0686'), uuidtobin('a22ce91e-d5dc-4f22-b247-e35c45aeacfa'), 'test92'),
      (uuidtobin('011294ea-e67a-4b75-9468-dbff21b56a00'), uuidtobin('011294ea-e67a-4b75-9468-dbff21b56a00'), uuidtobin('c9758c1f-8cc3-4fa8-a84b-d167fe19e7af'), 'test93'),
      (uuidtobin('01581b03-ec8f-4ac0-900f-0536de287356'), uuidtobin('01581b03-ec8f-4ac0-900f-0536de287356'), uuidtobin('188d4f44-92ef-44a6-9c38-99581ba485f4'), 'test94');

      create table test_pta like test;

      pt-archiver --source h=mariadb,P=3306,u=archiver,p=pass,D=testdb,t=test --dest h=mariadb,P=3306,u=archiver,p=pass,D=testdb,t=test_pta --no-delete --statistics --why-quit --limit 3 --commit-each --bulk-insert --where "1=1" --no-check-charset
       - pt-archiver output:

      Started at 2022-11-24T11:19:13, ended at 2022-11-24T11:19:13
      Source: D=testdb,P=3306,h=mariadb,p=...,t=test,u=archiver
      Dest: D=testdb,P=3306,h=mariadb,p=...,t=test_pta,u=archiver
      SELECT 13
      INSERT 0
      DELETE 0
      Action Count Time Pct
      bulk_inserting 5 0.0033 14.43
      select 6 0.0020 8.76
      commit 12 0.0019 8.21
      print_bulkfile 13 0.0000 0.15
      other 0 0.0157 68.44
      Exiting because there are no more rows.

      • Checks after archiving:

      CHECKSUM TABLE test;

      -----------------------+

      Table Checksum

      -----------------------+

      testdb.test 3905247765

      -----------------------+
      CHECKSUM TABLE test_pta;
      ---------------------------+

      Table Checksum

      ---------------------------+

      testdb.test_pta 4076662413

      ---------------------------+

      select uuidfrombin(id), uuidfrombin(bin2), uuidfrombin(bin3), name from test;

      --------------------------------------------------------------------------------------------------------------------+

      uuidfrombin(id) uuidfrombin(bin2) uuidfrombin(bin3) name

      --------------------------------------------------------------------------------------------------------------------+

      000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5 000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5 610025a5-71a6-4fde-a847-cf8612c2bccc test1
      0013c64f-4e33-4686-b068-7fc4a8de4441 0013c64f-4e33-4686-b068-7fc4a8de4441 1ede04fe-ffd0-4bf5-aaa6-572b7bbb9c5a test2
      0016274e-7898-4a39-9afb-5b4862a8f9c8 0016274e-7898-4a39-9afb-5b4862a8f9c8 e28fbe3b-64eb-414e-b676-194286e0c265 test3
      003dfde9-766d-4368-9b6c-e74acccfffbb 003dfde9-766d-4368-9b6c-e74acccfffbb 0dd90d22-0c86-4774-b167-4aef082e09af test4
      0051c6f8-e09d-44fa-9f26-ebbd8bbb0300 0051c6f8-e09d-44fa-9f26-ebbd8bbb0300 ea76a8e4-3f10-4711-83de-a999434e2a28 test5
      005dadfd-1370-4b8c-b17e-0b37905b3418 005dadfd-1370-4b8c-b17e-0b37905b3418 0fba7404-cfb1-4ad9-bb9c-b2361c50566d test6
      00b19468-4f84-49a7-b512-c033eb3ba6ee NULL 6a084fc5-b4d8-4b38-817a-f593755adf05 test7
      00c3948d-1212-40ff-8026-0c84c34bd236 00c3948d-1212-40ff-8026-0c84c34bd236 7a996b78-1996-4ad2-9c11-b597fdb4aaa0 test8
      00d51819-8494-4d6c-a9e9-0fe725750a22 00d51819-8494-4d6c-a9e9-0fe725750a22 6f83685f-4451-49bd-b464-ac4c508c2403 test9
      00f04079-f1a5-43b0-bf40-ea68bc4bd947 00f04079-f1a5-43b0-bf40-ea68bc4bd947 2f0f016a-caae-48e8-8490-67c8f09c4f23 test91
      01016c63-3a81-4969-b4b0-a83a463b0686 01016c63-3a81-4969-b4b0-a83a463b0686 a22ce91e-d5dc-4f22-b247-e35c45aeacfa test92
      011294ea-e67a-4b75-9468-dbff21b56a00 011294ea-e67a-4b75-9468-dbff21b56a00 c9758c1f-8cc3-4fa8-a84b-d167fe19e7af test93
      01581b03-ec8f-4ac0-900f-0536de287356 01581b03-ec8f-4ac0-900f-0536de287356 188d4f44-92ef-44a6-9c38-99581ba485f4 test94

      --------------------------------------------------------------------------------------------------------------------+
      select uuidfrombin(id), uuidfrombin(bin2), uuidfrombin(bin3), name from test_pta;

      --------------------------------------------------------------------------------------------------------------------+

      uuidfrombin(id) uuidfrombin(bin2) uuidfrombin(bin3) name

      --------------------------------------------------------------------------------------------------------------------+

      000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5 000f4cdd-c72b-4b77-8af8-cfe7ee15e0c5 610025a5-71a6-4fde-a847-cf8612c2bccc test1
      0013c64f-4e33-4686-b068-7fc4a8de4441 0013c64f-4e33-4686-b068-7fc4a8de4441 1ede04fe-ffd0-4bf5-aaa6-572b7bbb9c5a test2
      0016274e-7898-4a39-9afb-5b4862a8f9c8 0016274e-7898-4a39-9afb-5b4862a8f9c8 e28fbe3b-64eb-414e-b676-194286e0c265 test3
      003dfde9-766d-4368-9b6c-e74acccfffbb 003dfde9-766d-4368-9b6c-e74acccfffbb 0dd90d22-0c86-4774-b167-4aef082e09af test4
      0051c6f8-e09d-44fa-9f26-ebbd8bbb0300 0051c6f8-e09d-44fa-9f26-ebbd8bbb0300 ea76a8e4-3f10-4711-83de-a999434e2a28 test5
      005dadfd-1370-4b8c-b17e-0b37905b3418 005dadfd-1370-4b8c-b17e-0b37905b3418 0fba7404-cfb1-4ad9-bb9c-b2361c50566d test6
      00b19468-4f84-49a7-b512-c033eb3ba6ee 6a084fc5-b4d8-4b38-817a-f593755adf05 74657374-3700-0000-0000-000000000000 NULL
      00c3948d-1212-40ff-8026-0c84c34bd236 00c3948d-1212-40ff-8026-0c84c34bd236 7a996b78-1996-4ad2-9c11-b597fdb4aaa0 test8
      00d51819-8494-4d6c-a9e9-0fe725750a22 00d51819-8494-4d6c-a9e9-0fe725750a22 6f83685f-4451-49bd-b464-ac4c508c2403 test9
      00f04079-f1a5-43b0-bf40-ea68bc4bd947 00f04079-f1a5-43b0-bf40-ea68bc4bd947 2f0f016a-caae-48e8-8490-67c8f09c4f23 test91
      01016c63-3a81-4969-b4b0-a83a463b0686 01016c63-3a81-4969-b4b0-a83a463b0686 a22ce91e-d5dc-4f22-b247-e35c45aeacfa test92
      011294ea-e67a-4b75-9468-dbff21b56a00 011294ea-e67a-4b75-9468-dbff21b56a00 c9758c1f-8cc3-4fa8-a84b-d167fe19e7af test93
      01581b03-ec8f-4ac0-900f-0536de287356 01581b03-ec8f-4ac0-900f-0536de287356 188d4f44-92ef-44a6-9c38-99581ba485f4 NULL

      --------------------------------------------------------------------------------------------------------------------+

      Attachments

        Activity

          People

            aaditya.dubey Aaditya Dubey
            Galy Tin Cvitković
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Smart Checklist