Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
reader.fileSizeForLastIndex > 0
} catch {
case _: FileNotFoundException => false
case NonFatal(e) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I roughly remember this was pointed out earlier, but we wanted more elegant code and during finding we forgot the actual issue. Happy to see it fixed finally.

logWarning(s"Error while reading new log ${reader.rootPath}", e)
false
}

case NonFatal(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,55 @@ class FsHistoryProviderSuite extends SparkFunSuite with Matchers with Logging {
}
}

test("SPARK-33146: don't let one bad rolling log folder prevent loading other applications") {
withTempDir { dir =>
val conf = createTestConf(true)
conf.set(HISTORY_LOG_DIR, dir.getAbsolutePath)
val hadoopConf = SparkHadoopUtil.newConfiguration(conf)
val fs = new Path(dir.getAbsolutePath).getFileSystem(hadoopConf)

val provider = new FsHistoryProvider(conf)

val writer = new RollingEventLogFilesWriter("app", None, dir.toURI, conf, hadoopConf)
writer.start()

writeEventsToRollingWriter(writer, Seq(
SparkListenerApplicationStart("app", Some("app"), 0, "user", None),
SparkListenerJobStart(1, 0, Seq.empty)), rollFile = false)
provider.checkForLogs()
provider.cleanLogs()
assert(dir.listFiles().size === 1)
assert(provider.getListing.length === 1)

// Manually delete the appstatus file to make an invalid rolling event log
val appStatusPath = RollingEventLogFilesWriter.getAppStatusFilePath(new Path(writer.logPath),
"app", None, true)
fs.delete(appStatusPath, false)
provider.checkForLogs()
provider.cleanLogs()
assert(provider.getListing.length === 0)

// Create a new application
val writer2 = new RollingEventLogFilesWriter("app2", None, dir.toURI, conf, hadoopConf)
writer2.start()
writeEventsToRollingWriter(writer2, Seq(
SparkListenerApplicationStart("app2", Some("app2"), 0, "user", None),
SparkListenerJobStart(1, 0, Seq.empty)), rollFile = false)

// Both folders exist but only one application found
provider.checkForLogs()
provider.cleanLogs()
assert(provider.getListing.length === 1)
assert(dir.listFiles().size === 2)

// Make sure a new provider sees the valid application
provider.stop()
val newProvider = new FsHistoryProvider(conf)
newProvider.checkForLogs()
assert(newProvider.getListing.length === 1)
}
}

/**
* Asks the provider to check for logs and calls a function to perform checks on the updated
* app list. Example:
Expand Down