Skip to content
Snippets Groups Projects
Commit 3993ebca authored by Imran Rashid's avatar Imran Rashid Committed by Marcelo Vanzin
Browse files

[SPARK-17676][CORE] FsHistoryProvider should ignore hidden files

## What changes were proposed in this pull request?

FsHistoryProvider was writing a hidden file (to check the fs's clock).
Even though it deleted the file immediately, sometimes another thread
would try to scan the files on the fs in-between, and then there would
be an error msg logged which was very misleading for the end-user.
(The logged error was harmless, though.)

## How was this patch tested?

I added one unit test, but to be clear, that test was passing before.  The actual change in behavior in that test is just logging (after the change, there is no more logged error), which I just manually verified.

Author: Imran Rashid <irashid@cloudera.com>

Closes #15250 from squito/SPARK-17676.
parent 29396e7d
No related branches found
No related tags found
No related merge requests found
...@@ -294,7 +294,12 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock) ...@@ -294,7 +294,12 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
.filter { entry => .filter { entry =>
try { try {
val prevFileSize = fileToAppInfo.get(entry.getPath()).map{_.fileSize}.getOrElse(0L) val prevFileSize = fileToAppInfo.get(entry.getPath()).map{_.fileSize}.getOrElse(0L)
!entry.isDirectory() && prevFileSize < entry.getLen() !entry.isDirectory() &&
// FsHistoryProvider generates a hidden file which can't be read. Accidentally
// reading a garbage file is safe, but we would log an error which can be scary to
// the end-user.
!entry.getPath().getName().startsWith(".") &&
prevFileSize < entry.getLen()
} catch { } catch {
case e: AccessControlException => case e: AccessControlException =>
// Do not use "logInfo" since these messages can get pretty noisy if printed on // Do not use "logInfo" since these messages can get pretty noisy if printed on
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
package org.apache.spark.deploy.history package org.apache.spark.deploy.history
import java.io.{BufferedOutputStream, ByteArrayInputStream, ByteArrayOutputStream, File, import java.io._
FileOutputStream, OutputStreamWriter}
import java.net.URI import java.net.URI
import java.nio.charset.StandardCharsets import java.nio.charset.StandardCharsets
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
...@@ -394,6 +393,39 @@ class FsHistoryProviderSuite extends SparkFunSuite with BeforeAndAfter with Matc ...@@ -394,6 +393,39 @@ class FsHistoryProviderSuite extends SparkFunSuite with BeforeAndAfter with Matc
} }
} }
test("ignore hidden files") {
// FsHistoryProvider should ignore hidden files. (It even writes out a hidden file itself
// that should be ignored).
// write out one totally bogus hidden file
val hiddenGarbageFile = new File(testDir, ".garbage")
val out = new PrintWriter(hiddenGarbageFile)
// scalastyle:off println
out.println("GARBAGE")
// scalastyle:on println
out.close()
// also write out one real event log file, but since its a hidden file, we shouldn't read it
val tmpNewAppFile = newLogFile("hidden", None, inProgress = false)
val hiddenNewAppFile = new File(tmpNewAppFile.getParentFile, "." + tmpNewAppFile.getName)
tmpNewAppFile.renameTo(hiddenNewAppFile)
// and write one real file, which should still get picked up just fine
val newAppComplete = newLogFile("real-app", None, inProgress = false)
writeFile(newAppComplete, true, None,
SparkListenerApplicationStart(newAppComplete.getName(), Some("new-app-complete"), 1L, "test",
None),
SparkListenerApplicationEnd(5L)
)
val provider = new FsHistoryProvider(createTestConf())
updateAndCheck(provider) { list =>
list.size should be (1)
list(0).name should be ("real-app")
}
}
/** /**
* Asks the provider to check for logs and calls a function to perform checks on the updated * Asks the provider to check for logs and calls a function to perform checks on the updated
* app list. Example: * app list. Example:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment