You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Cheng Lian (JIRA)" <ji...@apache.org> on 2015/06/06 10:52:00 UTC

[jira] [Comment Edited] (SPARK-8079) NPE when HadoopFsRelation.prepareForWriteJob throws exception

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

Cheng Lian edited comment on SPARK-8079 at 6/6/15 8:51 AM:
-----------------------------------------------------------

Bascially, in {{InsertIntoHadoopFsRelation}} we need to be careful whenever a user defined method is invoked.  Because they may throw unexpected exception and causes the write job/task to abort.  More specifically, we need to keep an eye on the following methods:

- {{HadoopFsRelation.prepareForWriteJob}}: This method is called on the driver side *before* the write job is issued. It initializes the write job by decorating the {{job}} instance passed in, and returning an {{OutputWriterFactory}} which produces {{OutputWriter}} instances on the executor side. Note that, if this method throws any exception, we should *not* abort the job since the job hasn't been issued yet. Especially, the {{OutputCommitter}} used to commit/abort the job may not be properly initialized yet (which is the case described in this ticket).
- {{OutputWriter.<init>}}, {{OutputWriter.write}}, and {{OutputWriter.close}}: These methods are called on executor side while a write task is being executed. Failures of these methods require task abortion.


was (Author: lian cheng):
Bascially, in {{InsertIntoHadoopFsRelation}} we need to be careful whenever a user defined method is invoked.  Because they may throw unexpected exception and causes the write job/task to abort.

> NPE when HadoopFsRelation.prepareForWriteJob throws exception
> -------------------------------------------------------------
>
>                 Key: SPARK-8079
>                 URL: https://issues.apache.org/jira/browse/SPARK-8079
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.4.0
>            Reporter: Cheng Lian
>            Assignee: Cheng Lian
>
> Take {{ParquetRelation2}} as an example, the following Spark shell code may cause an unexpected NPE:
> {code}
> import sqlContext._
> import sqlContext.implicits._
> range(1, 3).select($"id" as "a b").write.format("parquet").save("file:///tmp/foo")
> {code}
> Exceptions thrown:
> {noformat}
> import sqlContext._
> import sqlContext.implicits._
> range(1, 3).select($"id" as "a b").write.format("parquet").save("file:///tmp/foo")
> java.lang.RuntimeException: Attribute name "a b" contains invalid character(s) among " ,;{}()   =". Please use alias to rename it.
>         at scala.sys.package$.error(package.scala:27)
>         at org.apache.spark.sql.parquet.ParquetTypesConverter$$anonfun$checkSpecialCharacters$2.apply(ParquetTypes.scala:414)
>         at org.apache.spark.sql.parquet.ParquetTypesConverter$$anonfun$checkSpecialCharacters$2.apply(ParquetTypes.scala:412)
>         at scala.collection.immutable.List.foreach(List.scala:318)
>         at org.apache.spark.sql.parquet.ParquetTypesConverter$.checkSpecialCharacters(ParquetTypes.scala:412)
>         at org.apache.spark.sql.parquet.ParquetTypesConverter$.convertToString(ParquetTypes.scala:423)
>         at org.apache.spark.sql.parquet.RowWriteSupport$.setSchema(ParquetTableSupport.scala:383)
>         at org.apache.spark.sql.parquet.ParquetRelation2.prepareJobForWrite(newParquet.scala:230)
>         ...
> java.lang.NullPointerException
>         at org.apache.spark.sql.sources.BaseWriterContainer.abortJob(commands.scala:372)
>         at org.apache.spark.sql.sources.InsertIntoHadoopFsRelation.insert(commands.scala:137)
>         at org.apache.spark.sql.sources.InsertIntoHadoopFsRelation.run(commands.scala:114)
>         at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult$lzycompute(commands.scala:57)
>         at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult(commands.scala:57)
>         ...
> {noformat}
> Note that the first {{RuntimeException}} is expected, while the following NPE is not.
> The reason of the NPE is that, {{BaseWriterContainer.driverSideSetup()}} calls {{relation.prepareForWriteJob()}} AND initializes the {{OutputCommitter}} used for the subsequent write job. However, if the former throws an exception, the latter is not properly initialized, thus an NPE is thrown when aborting the job because the {{OutputCommitter}} is still null.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org