0
votes

I was trying to execute hive ACID transaction properties in Hive 0.14 like insert, delete and update through Java.I am able to set the required ACID transaction properties. Also able to create the table with transaction properties. But it's failing. Below is the sample code :

public class HiveJdbcClient {
    private static String driverName = "org.apache.hive.jdbc.HiveDriver";

    public static void main(String[] args) throws SQLException {
        try {
            Class.forName(driverName);
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
        }
        Connection con = DriverManager.getConnection("jdbc:hive2://ipaddress:port/default", "user", "password");
        Statement stmt = con.createStatement();

        stmt.execute("set set hive.support.concurrency=true");
        stmt.execute("set hive.enforce.bucketing=true");
        stmt.execute("set hive.exec.dynamic.partition.mode=nonstrict");
        stmt.execute("set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
        stmt.execute("set hive.compactor.initiator.on=true");
        stmt.execute("set hive.compactor.worker.threads=2");



        String tableName = "hive_acid_test";

        stmt.execute("drop table if exists " + tableName);


        stmt.execute("create table " + tableName + " (id int, name string,department string) clustered by (department) into 3 buckets stored as orc TBLPROPERTIES   ('transactional'='true')");


        stmt.execute("insert into table hive_acid_test values(1,'jon','sales')");
    }
}

Getting the following exception while trying to insert:

Exception in thread "main" java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:296) at promo.hive.sample.HiveJdbcClient.main(HiveJdbcClient.java:49)

The same insert command is working from command line. Please help me find the issue.

1
there is a similar thread here: hortonworks.com/community/forums/topic/… - Barett
This link not leading to a solution. There is no permission exception here. - Sachin

1 Answers

0
votes

I was able to reproduce issue and checked hive server logs- hiveserver2.log. This was now a known issue - https://issues.apache.org/jira/browse/HIVE-8326 It is fixed in Hive version 1.1

Issue is related to DbTxManager used in your ACID configuration.

Error Logs:

java.lang.NullPointerException
        at org.apache.hadoop.hive.ql.lockmgr.DbTxnManager.heartbeat(DbTxnManager.java:254)
        at org.apache.hadoop.hive.ql.exec.Heartbeater.heartbeat(Heartbeater.java:81)
        at org.apache.hadoop.hive.ql.exec.mr.HadoopJobExecHelper.progress(HadoopJobExecHelper.java:242)
        at org.apache.hadoop.hive.ql.exec.mr.HadoopJobExecHelper.progress(HadoopJobExecHelper.java:547)
        at org.apache.hadoop.hive.ql.exec.mr.ExecDriver.execute(ExecDriver.java:435)
        at org.apache.hadoop.hive.ql.exec.mr.MapRedTask.execute(MapRedTask.java:137)
        at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)
        at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:85)
        at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1604)
        at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1364)
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1177)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1004)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:999)