Github user chhao01 commented on a diff in the pull request:
https://github.com/apache/spark/pull/8023#discussion_r37487474
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
@@ -156,10 +165,27 @@ private[sql] class CacheManager(sqlContext:
SQLContext) extends Logging {
* function will over invalidate.
*/
private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
- cachedData.foreach {
- case data if data.plan.collect { case p if p.sameResult(plan) => p
}.nonEmpty =>
- data.cachedRepresentation.recache()
- case _ =>
+ var i = 0
+ var locatedIdx = -1
+ // find the index of the cached data, according to the specified
logical plan
+ while (i < cachedData.length && locatedIdx < 0) {
+ cachedData(i) match {
+ case data if data.plan.collect { case p if p.sameResult(plan) => p
}.nonEmpty =>
+ locatedIdx = i
+ case _ =>
+ }
+ i += 1
+ }
+
+ if (locatedIdx >= 0) {
+ // if the cached data exists, remove it from the cache data list, as
we need to
+ // re-generate the spark plan, and we don't want the this to be used
during the
+ // re-generation
--- End diff --
In `SQLContext.QueryExecution`, we always try to load the cached
`PhysicalRDD` according to the logical plan first, if we don't remove it from
the cached list, then we will always get the stale one, which is not what we
want, right?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]