Skip to content
Closed
Prev Previous commit
Next Next commit
Replace refresh with invalidate to be on the safe side
  • Loading branch information
Changgyoo Park committed Jun 19, 2024
commit 9c24efdd8989c2bab441dd2a61004cb65de35787
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,9 @@ object SparkSession extends Logging {
.getOrElse({
var existingSession = sessions.get(builder.configuration)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a lock here for sessions?

Copy link
Author

Choose a reason for hiding this comment

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

I don't think so as Cache is backed by ConcurrentMap which allows concurrent access to the data. Source: https://guava.dev/releases/17.0/api/docs/com/google/common/cache/CacheBuilder.html.

if (!existingSession.client.isSessionValid) {
// If the cached session has become invalid, e.g., due to a server restart, this creates
// a new one and returns it.
sessions.refresh(builder.configuration)
// If the cached session has become invalid, e.g., due to a server restart, the cache
// entry is invalidated.
sessions.invalidate(builder.configuration)
existingSession = sessions.get(builder.configuration)
}
existingSession
Expand Down