You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/07 09:55:36 UTC

[GitHub] [shardingsphere] ReyYang opened a new issue #14604: "Data truncated for column" error occurs during the migration of the year type field

ReyYang opened a new issue #14604:
URL: https://github.com/apache/shardingsphere/issues/14604


   "Data truncated for column" error occurs during the migration of the year type field
   ### Which version of ShardingSphere did you use?
   master branch
   MySQL 5.6,5.7
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Scaling
   ### Expected behavior
   Successful migration
   ### Actual behavior
   "Data truncated for column" error occurs during the migration of the year type field
   ### Reason analyze (If you can)
   The year data type in MySQL can be expressed as either Date or Integer
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   ```sql
   -- create table
   create table table_date
   (
       id          bigint 
           primary key,
       shard_id    bigint    not null,
       t_date      date      null,
       t_time      time      null,
       t_datetime  datetime  null,
       t_timestamp timestamp null,
       t_year      year      null
   );
   
   -- insert datas
   insert into table_date (id, shard_id, t_date, t_time,
                             t_datetime, t_timestamp, t_year)
   VALUES (1, 1, '1997-10-13', '13:01:45', '1997-10-13 13:01:45', '1997-10-13 13:01:45', 1997),
          (2, 2, '1998-10-14', '14:01:45', '1998-10-14 14:01:45', '1998-10-14 14:01:45', 1998),
          (3, 4, '1999-10-15', '15:01:45', '1999-10-15 15:01:45', '1999-10-13 15:01:45', 1999),
          (4, 6, '2000-10-16', '16:01:45', '2000-10-16 16:01:45', '2000-10-16 16:01:45', 2000),
          (5, 3, '2001-10-17', '17:01:45', '2001-10-17 17:01:45', '2001-10-17 17:01:45', 2001),
          (6, 5, '2002-10-18', '18:01:45', '2002-10-18 18:01:45', '2002-10-18 18:01:45', 2002);
   -- 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_date (
       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)))
   );
   ```
   throw exception
   ```java
   [ERROR] 2022-01-07 15:59:48.581 [ShardingSphere-Scaling-execute-1] o.a.s.d.p.c.i.AbstractImporter - flush failed 0/3 times.
   java.sql.BatchUpdateException: Data truncated for column 't_year' at row 1
   	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
   	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
   	at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
   	at com.mysql.jdbc.Util.getInstance(Util.java:408)
   	at com.mysql.jdbc.SQLError.createBatchUpdateException(SQLError.java:1163)
   	at com.mysql.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1632)
   	at com.mysql.jdbc.PreparedStatement.executeBatchInternal(PreparedStatement.java:1298)
   	at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:970)
   	at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
   	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
   	at org.apache.shardingsphere.driver.executor.batch.BatchPreparedStatementExecutor$1.executeSQL(BatchPreparedStatementExecutor.java:143)
   	at org.apache.shardingsphere.driver.executor.batch.BatchPreparedStatementExecutor$1.executeSQL(BatchPreparedStatementExecutor.java:139)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:85)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:64)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:101)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.serialExecute(ExecutorEngine.java:87)
   	at org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:81)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:65)
   	at org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:49)
   	at org.apache.shardingsphere.driver.executor.batch.BatchPreparedStatementExecutor.executeBatch(BatchPreparedStatementExecutor.java:152)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeBatch(ShardingSpherePreparedStatement.java:497)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.executeBatchInsert(AbstractImporter.java:179)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.doFlush(AbstractImporter.java:154)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.tryFlush(AbstractImporter.java:139)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.flushInternal(AbstractImporter.java:130)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.lambda$flush$2(AbstractImporter.java:121)
   	at java.util.ArrayList.forEach(ArrayList.java:1257)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.flush(AbstractImporter.java:116)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.write(AbstractImporter.java:97)
   	at org.apache.shardingsphere.data.pipeline.core.importer.AbstractImporter.start(AbstractImporter.java:86)
   	at org.apache.shardingsphere.data.pipeline.api.executor.AbstractLifecycleExecutor.run(AbstractLifecycleExecutor.java:47)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
   	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
   	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   Caused by: java.sql.SQLException: Data truncated for column 't_year' at row 1
   	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3914)
   	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
   	at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1288)
   	at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:788)
   	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2124)
   	at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2058)
   	at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5158)
   	at com.mysql.jdbc.PreparedStatement.executeBatchedInserts(PreparedStatement.java:1593)
   	... 32 common frames omitted
   ```
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] sandynz closed issue #14604: "Data truncated for column" error occurs during the migration of the year type field

Posted by GitBox <gi...@apache.org>.
sandynz closed issue #14604:
URL: https://github.com/apache/shardingsphere/issues/14604


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org