[ 
https://issues.apache.org/jira/browse/HIVE-12779?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15307573#comment-15307573
 ] 

Oleksiy Sayankin commented on HIVE-12779:
-----------------------------------------

Alina has found a workaround for this issue.

*ROOT-CAUSE:*

Consider method 

{code}
  protected int require (int required) throws KryoException 
{code}

from class com.esotericsoftware.kryo.io.Input where exception happens. 

{code}
  int remaining = limit - position;
  if (remaining >= required) return remaining;
  if (required > capacity) throw new KryoException("Buffer too small: capacity:
" + capacity + ", required: " + required);

  int count;
  // Try to fill the buffer.
  if (remaining > 0) {
  count = fill(buffer, limit, capacity - limit);
  if (count == -1) throw new KryoException("Buffer underflow.");
{code}

We can see that exception ("Buffer underflow.") occurs when count == -1. So let 
us see method fill(byte[] buffer, int offset, int count) in details:
{code}
  if (inputStream == null) return -1;
  try {
  return inputStream.read(buffer, offset, count);
  } catch (IOException ex) {
  throw new KryoException(ex);
  }
{code}

It returns -1 either when inputStream == null or from inputStream.read(buffer, 
offset, count). We definitely know that inputStream can not be equal null here 
because of constructor:

{code}
  public Input (InputStream inputStream) {
    this(4096);
    if (inputStream == null) throw new IllegalArgumentException("inputStream
cannot be null.");
    this.inputStream = inputStream;
    }
{code}

>From Java docs we know that if no byte is available because the stream is at 
>end of file, the value -1 is returned by the method  inputStream.read(buffer, 
>offset, count). Hence we suspect here some errors in HDFS  here that causes -1 
>to be a return value. Skipping usage of file system as query plan storage and 
>sending it via RPC directly will fix the issue.


*SOLUTION:*

Use 

{code}
  <property>
    <name>hive.rpc.query.plan</name>
    <value>true</value>
  </property>
{code}

in hive-site.xml as workaround. This property defines whether to send the query 
plan via local resource or RPC.

> Buffer underflow when inserting data to table
> ---------------------------------------------
>
>                 Key: HIVE-12779
>                 URL: https://issues.apache.org/jira/browse/HIVE-12779
>             Project: Hive
>          Issue Type: Bug
>          Components: Database/Schema, SQL
>         Environment: CDH 5.4.9
>            Reporter: Ming Hsuan Tu
>            Assignee: Alan Gates
>
> I face a buffer underflow problem when inserting data to table from hive 
> 1.1.0.
> the block size is 128 MB and the data size is only 10MB, but it gives me 891 
> mappers.
> Task with the most failures(4):
> -----
> Task ID:
>   task_1451989578563_0001_m_000008
> URL:
>   
> http://0.0.0.0:8088/taskdetails.jsp?jobid=job_1451989578563_0001&tipid=task_1451989578563_0001_m_000008
> -----
> Diagnostic Messages for this Task:
> Error: java.lang.RuntimeException: Failed to load plan: 
> hdfs://tpe-nn-3-1:8020/tmp/hive/alec.tu/af798488-dbf5-45da-8adb-e4f2ddde1242/hive_2016-01-05_18-34-26_864_3947114301988950007-1/-mr-10004/bb86c923-0dca-43cd-aa5d-ef575d764e06/map.xml:
>  org.apache.hive.com.esotericsoftware.kryo.KryoException: Buffer underflow.
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.getBaseWork(Utilities.java:450)
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.getMapWork(Utilities.java:296)
>         at 
> org.apache.hadoop.hive.ql.io.HiveInputFormat.init(HiveInputFormat.java:268)
>         at 
> org.apache.hadoop.hive.ql.io.HiveInputFormat.getRecordReader(HiveInputFormat.java:234)
>         at 
> org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getRecordReader(CombineHiveInputFormat.java:701)
>         at 
> org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:169)
>         at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:432)
>         at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
>         at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163)
>         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:1671)
>         at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
> Caused by: org.apache.hive.com.esotericsoftware.kryo.KryoException: Buffer 
> underflow.
>         at 
> org.apache.hive.com.esotericsoftware.kryo.io.Input.require(Input.java:181)
>         at 
> org.apache.hive.com.esotericsoftware.kryo.io.Input.readBoolean(Input.java:783)
>         at 
> org.apache.hive.com.esotericsoftware.kryo.serializers.UnsafeCacheFields$UnsafeBooleanField.read(UnsafeCacheFields.java:120)
>         at 
> org.apache.hive.com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:507)
>         at 
> org.apache.hive.com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:672)
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.deserializeObjectByKryo(Utilities.java:1069)
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.deserializePlan(Utilities.java:960)
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.deserializePlan(Utilities.java:974)
>         at 
> org.apache.hadoop.hive.ql.exec.Utilities.getBaseWork(Utilities.java:416)
>         ... 12 more
> Container killed by the ApplicationMaster.
> Container killed on request. Exit code is 143
> Container exited with a non-zero exit code 143
> Thank you.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to