shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

The binary type is abnormal during the data migration data check phase

Open ReyYang opened this issue 4 years ago • 0 comments

The binary type is abnormal during the data migration data check phase

Which version of ShardingSphere did you use?

master branch MySQL5.6,5.7

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

Sharding-Scalinlg

Expected behavior

Successful migration

Actual behavior

Migration data check phase failed

Reason analyze (If you can)

The binary type found in source is Blob, and the type found in target is byte[] Possible problem location: org.apache.shardingsphere.data.pipeline.core.check.consistency.DataConsistencyCheckerImpl#checkRecordsContent

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

-- create table
create table table_string
(
    id          bigint 
        primary key,
    shard_id    bigint               not null,
    t_char      char                 null,
    t_varchar   varchar(100)         null,
    t_binary    binary(1)            null,
    t_varbinary varbinary(100)       null,
    t_blob      blob                 null,
    t_text      text                 null,
    t_enum      enum ('1', '2', '3') null,
    t_set       set ('1', '2', '3')  null
);
-- insert datas
insert into table_string (id, shard_id, t_char, t_varchar,
                            t_binary, t_varbinary,
                            t_blob, t_text, t_enum, t_set)
VALUES (1, 2, 'n', 'nihao shijie', 0, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '1', '1'),
       (2, 1, 'i', 'nihao shijie', 1, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '2', '3'),
       (3, 3, 'h', 'nihao shijie', 1, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '3', '1'),
       (4, 6, 'a', 'nihao shijie', 0, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '2', '1'),
       (5, 5, 'o', 'nihao shijie', 1, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '3', '3'),
       (6, 4, 'b', 'nihao shijie', 0, '0101110', 'testtesttesttest\stesttesttest', 'testtesttesttest', '3', '2');

-- add resource
ADD RESOURCE ds_2 (
    URL="jdbc:mysql://127.0.0.1:3306/demo_ds_2?serverTimezone=UTC&useSSL=false",
    USER=root,
    PASSWORD=123456,
    PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
), ds_3 (
    URL="jdbc:mysql://127.0.0.1:3306/demo_ds_3?serverTimezone=UTC&useSSL=false",
    USER=root,
    PASSWORD=123456,
    PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
);
-- start scaling
ALTER SHARDING TABLE RULE table_string (
    RESOURCES(ds_2,ds_3),
    SHARDING_COLUMN=id,
    TYPE(NAME=HASH_MOD,PROPERTIES("sharding-count"=2)),
    GENERATED_KEY(COLUMN=id,TYPE(NAME=snowflake,PROPERTIES("worker-id"=123)))
);

data check

[INFO ] 2022-01-07 18:03:00.045 [_finished_check_Worker-1] o.a.s.d.p.c.a.i.PipelineJobAPIImpl - Data consistency check for job 401487516776231
[INFO ] 2022-01-07 18:03:00.053 [_finished_check_Worker-1] o.a.s.s.s.ShardingRuleAlteredJobConfigurationPreparer - toTaskConfigs, dataSourceName=ds_0, taskConfig=TaskConfiguration(handleConfig=HandleConfiguration(jobId=401487516776231, concurrency=3, retryTimes=3, tablesFirstDataNodes=table_string:ds_0.table_string_0, jobShardingDataNodes=[table_string:ds_0.table_string_0,ds_0.table_string_1, table_string:ds_1.table_string_0,ds_1.table_string_1], logicTables=table_string, jobShardingItem=0, shardingSize=10000000, sourceDatabaseType=MySQL, targetDatabaseType=MySQL), dumperConfig=DumperConfiguration(dataSourceName=ds_0, blockQueueSize=10000, position=null, tableNameMap={table_string_0=table_string, table_string_1=table_string}), importerConfig=ImporterConfiguration(shardingColumnsMap={table_string=[id]}, retryTimes=3))
[INFO ] 2022-01-07 18:03:00.392 [_finished_check_Worker-1] o.a.s.d.p.c.a.i.PipelineJobAPIImpl - Scaling job 401487516776231 with check algorithm 'org.apache.shardingsphere.data.pipeline.core.spi.check.consistency.DataMatchDataConsistencyCheckAlgorithm' data consistency checker result {table_string=DataConsistencyCheckResult(sourceRecordsCount=6, targetRecordsCount=6, recordsCountMatched=true, recordsContentMatched=false)}
[ERROR] 2022-01-07 18:03:00.392 [_finished_check_Worker-1] o.a.s.d.p.c.a.i.PipelineJobAPIImpl - Scaling job: 401487516776231, table: table_string data consistency check failed, recordsContentMatched: false, recordsCountMatched: true
[INFO ] 2022-01-07 18:03:00.392 [_finished_check_Worker-1] o.a.s.d.p.c.a.i.GovernanceRepositoryAPIImpl - persist job check result 'false' for job 401487516776231
[ERROR] 2022-01-07 18:03:00.394 [_finished_check_Worker-1] o.a.s.d.p.c.a.i.PipelineJobAPIImpl - Scaling job: 401487516776231, table: table_string data consistency check failed, recordsContentMatched: false, recordsCountMatched: true
[ERROR] 2022-01-07 18:03:00.394 [_finished_check_Worker-1] o.a.s.d.p.core.job.FinishedCheckJob - data consistency check failed, job 401487516776231

Example codes for reproduce this issue (such as a github link).

ReyYang avatar Jan 07 '22 10:01 ReyYang