zoukankan      html  css  js  c++  java
  • Sqoop报错Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction

    Error: java.io.IOException: Can't export data, please check failed map task logs
        at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:112)
        at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:39)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
        at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
    Caused by: java.io.IOException: java.sql.BatchUpdateException: Deadlock found when trying to get lock; try restarting transaction
        at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.write(AsyncSqlRecordWriter.java:220)
        at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.write(AsyncSqlRecordWriter.java:46)
        at org.apache.hadoop.mapred.MapTask$NewDirectOutputCollector.write(MapTask.java:658)
        at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
        at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112)
        at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:84)
        ... 10 more
    Caused by: java.sql.BatchUpdateException: Deadlock found when trying to get lock; try restarting transaction
        at com.mysql.jdbc.SQLError.createBatchUpdateException(SQLError.java:1167)
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1772)
        at com.mysql.jdbc.PreparedStatement.executeBatchInternal(PreparedStatement.java:1262)
        at com.mysql.jdbc.StatementImpl.executeBatch(StatementImpl.java:970)
        at org.apache.sqoop.mapreduce.AsyncSqlOutputFormat$AsyncSqlExecThread.run(AsyncSqlOutputFormat.java:231)
    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.Util.getInstance(Util.java:408)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:951)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2487)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
        at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1756)
        ... 3 more

    sqoop导出数据从hive到mysql报错

    sqoop配置如下:

    bin/sqoop export
    --connect jdbc:mysql://ip:3306/database?tinyInt1isBit=false
    --username xxx
    --password xxx
    --table xxx
    --update-key dt,xxx,xxx
    --update-mode updateonly
    --export-dir /xxx/xxx
    --fields-terminated-by '01'
    -m 4

    设置发现:

    --update-key 设置为--update-mode updateonly模式时,则报错 。

    --update-key 设置为--update-mode allowinsert模式时,不报错。

    看日志报错信息为mysql死锁问题,但未发现具体原因发生在什么地方 。

    排错后,发现mysql中没有使用联合索引,当在mysql中增加对应的mysql联合ENGINE=InnoDB索引时,不在报错。

    alter table tmp_table add  key d_x_x_x (dt,xx,xx,xx,xx,xx) ;

  • 相关阅读:
    IP分片与TCP分片的考虑
    snort-2.9.16在ubuntu16.04环境下的安装,配置与运行
    snort 程序流程图
    宿主机、容器、真实时间不一致问题
    ffi动态链接库的使用
    docker容器中nginx日志的分割
    dockerFile指令详解
    关于如何查看多网卡物理机中网卡序号与物理网卡的对应该关系
    Curl相关参数意义及使用方式
    docker 基础入门
  • 原文地址:https://www.cnblogs.com/-courage/p/14024701.html
Copyright © 2011-2022 走看看