Skip to content
Apache Spark
Branch: master
Clone or download
2 authors and HyukjinKwon [SPARK-27676][SQL][SS] InMemoryFileIndex should respect spark.sql.fil…
…es.ignoreMissingFiles

## What changes were proposed in this pull request?

Spark's `InMemoryFileIndex` contains two places where `FileNotFound` exceptions are caught and logged as warnings (during [directory listing](https://github.com/apache/spark/blob/bcd3b61c4be98565352491a108e6394670a0f413/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala#L274) and [block location lookup](https://github.com/apache/spark/blob/bcd3b61c4be98565352491a108e6394670a0f413/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala#L333)). This logic was added in #15153 and #21408.

I think that this is a dangerous default behavior because it can mask bugs caused by race conditions (e.g. overwriting a table while it's being read) or S3 consistency issues (there's more discussion on this in the [JIRA ticket](https://issues.apache.org/jira/browse/SPARK-27676)). Failing fast when we detect missing files is not sufficient to make concurrent table reads/writes or S3 listing safe (there are other classes of eventual consistency issues to worry about), but I think it's still beneficial to throw exceptions and fail-fast on the subset of inconsistencies / races that we _can_ detect because that increases the likelihood that an end user will notice the problem and investigate further.

There may be some cases where users _do_ want to ignore missing files, but I think that should be an opt-in behavior via the existing `spark.sql.files.ignoreMissingFiles` flag (the current behavior is itself race-prone because a file might be be deleted between catalog listing and query execution time, triggering FileNotFoundExceptions on executors (which are handled in a way that _does_ respect `ignoreMissingFIles`)).

This PR updates `InMemoryFileIndex` to guard the log-and-ignore-FileNotFoundException behind the existing `spark.sql.files.ignoreMissingFiles` flag.

**Note**: this is a change of default behavior, so I think it needs to be mentioned in release notes.

## How was this patch tested?

New unit tests to simulate file-deletion race conditions, tested with both values of the `ignoreMissingFIles` flag.

Closes #24668 from JoshRosen/SPARK-27676.

Lead-authored-by: Josh Rosen <rosenville@gmail.com>
Co-authored-by: Josh Rosen <joshrosen@stripe.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
Latest commit d83f84a Jun 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github [MINOR][DOCS] Tighten up some key links to the project and download p… May 21, 2019
R [SPARK-18570][ML][R] RFormula support * and ^ operators Jun 4, 2019
assembly [SPARK-27300][GRAPH] Add Spark Graph modules and dependencies Jun 9, 2019
bin [SPARK-27626][K8S] Fix `docker-image-tool.sh` to be robust in non-bas… May 3, 2019
build [SPARK-27979][BUILD][test-maven] Remove deprecated `--force` option i… Jun 11, 2019
common [SPARK-27622][CORE] Avoiding the network when block manager fetches d… Jun 25, 2019
conf [SPARK-27796][MESOS] Remove obsolete spark-mesos Dockerfile example May 21, 2019
core [SPARK-27630][CORE] Properly handle task end events from completed st… Jun 25, 2019
data [SPARK-22666][ML][SQL] Spark datasource for image format Sep 5, 2018
dev [SPARK-7721][INFRA][FOLLOW-UP] Remove cloned coverage repo after post… Jun 25, 2019
docs [SPARK-27676][SQL][SS] InMemoryFileIndex should respect spark.sql.fil… Jun 26, 2019
examples [SPARK-28056][PYTHON] add doc for SCALAR_ITER Pandas UDF Jun 18, 2019
external [SPARK-28142][SS] Use CaseInsensitiveStringMap for KafkaContinuousStream Jun 24, 2019
graph [SPARK-27300][GRAPH] Add Spark Graph modules and dependencies Jun 9, 2019
graphx [SPARK-27682][CORE][GRAPHX][MLLIB] Replace use of collections and met… May 15, 2019
hadoop-cloud [SPARK-27175][BUILD] Upgrade hadoop-3 to 3.2.0 Mar 17, 2019
launcher [SPARK-27610][YARN] Shade netty native libraries May 7, 2019
licenses-binary [SPARK-27358][UI] Update jquery to 1.12.x to pick up security fixes Apr 5, 2019
licenses [SPARK-27557][DOC] Add copy button to Python API docs for easier copy… May 1, 2019
mllib-local [SPARK-19591][ML][MLLIB] Add sample weights to decision trees Jan 25, 2019
mllib [SPARK-28154][ML][FOLLOWUP] GMM fix double caching Jun 25, 2019
project [SPARK-27630][CORE] Properly handle task end events from completed st… Jun 25, 2019
python [SPARK-28045][ML][PYTHON] add missing RankingEvaluator Jun 25, 2019
repl [SPARK-20547][REPL] Throw RemoteClassLoadedError for transient errors… May 28, 2019
resource-managers [SPARK-27823][CORE] Refactor resource handling code Jun 19, 2019
sbin [SPARK-27056][MESOS] Remove start-shuffle-service.sh Mar 9, 2019
sql [SPARK-27676][SQL][SS] InMemoryFileIndex should respect spark.sql.fil… Jun 26, 2019
streaming [SPARK-28101][DSTREAM][TEST] Fix Flaky Test: `InputStreamsSuite.Modif… Jun 19, 2019
tools [SPARK-25956] Make Scala 2.12 as default Scala version in Spark 3.0 Nov 15, 2018
.gitattributes [SPARK-3870] EOL character enforcement Oct 31, 2014
.gitignore [MINOR][DOC] Documentation on JVM options for SBT Jan 23, 2019
CONTRIBUTING.md [MINOR][DOCS] Tighten up some key links to the project and download p… May 21, 2019
LICENSE [SPARK-27557][DOC] Add copy button to Python API docs for easier copy… May 1, 2019
LICENSE-binary [SPARK-27300][GRAPH] Add Spark Graph modules and dependencies Jun 9, 2019
NOTICE [SPARK-23654][BUILD] remove jets3t as a dependency of spark Aug 16, 2018
NOTICE-binary [SPARK-27862][BUILD] Move to json4s 3.6.6 May 31, 2019
README.md [MINOR][DOCS] Tighten up some key links to the project and download p… May 21, 2019
appveyor.yml [SPARK-25944][R][BUILD] AppVeyor change to latest R version (3.6.0) May 28, 2019
pom.xml [SPARK-28111][BUILD] Upgrade `xbean-asm7-shaded` to 4.14 Jun 20, 2019
scalastyle-config.xml [SPARK-25986][BUILD] Add rules to ban throw Errors in application code Nov 14, 2018

README.md

Apache Spark

Spark is a unified analytics engine for large-scale data processing. It provides high-level APIs in Scala, Java, Python, and R, and an optimized engine that supports general computation graphs for data analysis. It also supports a rich set of higher-level tools including Spark SQL for SQL and DataFrames, MLlib for machine learning, GraphX for graph processing, and Structured Streaming for stream processing.

https://spark.apache.org/

Jenkins Build AppVeyor Build PySpark Coverage

Online Documentation

You can find the latest Spark documentation, including a programming guide, on the project web page. This README file only contains basic setup instructions.

Building Spark

Spark is built using Apache Maven. To build Spark and its example programs, run:

build/mvn -DskipTests clean package

(You do not need to do this if you downloaded a pre-built package.)

You can build Spark using more than one thread by using the -T option with Maven, see "Parallel builds in Maven 3". More detailed documentation is available from the project site, at "Building Spark".

For general development tips, including info on developing Spark using an IDE, see "Useful Developer Tools".

Interactive Scala Shell

The easiest way to start using Spark is through the Scala shell:

./bin/spark-shell

Try the following command, which should return 1,000,000,000:

scala> spark.range(1000 * 1000 * 1000).count()

Interactive Python Shell

Alternatively, if you prefer Python, you can use the Python shell:

./bin/pyspark

And run the following command, which should also return 1,000,000,000:

>>> spark.range(1000 * 1000 * 1000).count()

Example Programs

Spark also comes with several sample programs in the examples directory. To run one of them, use ./bin/run-example <class> [params]. For example:

./bin/run-example SparkPi

will run the Pi example locally.

You can set the MASTER environment variable when running examples to submit examples to a cluster. This can be a mesos:// or spark:// URL, "yarn" to run on YARN, and "local" to run locally with one thread, or "local[N]" to run locally with N threads. You can also use an abbreviated class name if the class is in the examples package. For instance:

MASTER=spark://host:7077 ./bin/run-example SparkPi

Many of the example programs print usage help if no params are given.

Running Tests

Testing first requires building Spark. Once Spark is built, tests can be run using:

./dev/run-tests

Please see the guidance on how to run tests for a module, or individual tests.

There is also a Kubernetes integration test, see resource-managers/kubernetes/integration-tests/README.md

A Note About Hadoop Versions

Spark uses the Hadoop core library to talk to HDFS and other Hadoop-supported storage systems. Because the protocols have changed in different versions of Hadoop, you must build Spark against the same version that your cluster runs.

Please refer to the build documentation at "Specifying the Hadoop Version and Enabling YARN" for detailed guidance on building for a particular distribution of Hadoop, including building for particular Hive and Hive Thriftserver distributions.

Configuration

Please refer to the Configuration Guide in the online documentation for an overview on how to configure Spark.

Contributing

Please review the Contribution to Spark guide for information on how to get started contributing to the project.

You can’t perform that action at this time.