diff --git a/core/src/main/scala/org/apache/spark/sql/TiContext.scala b/core/src/main/scala/org/apache/spark/sql/TiContext.scala index b45bf8d540..4be81bb05e 100644 --- a/core/src/main/scala/org/apache/spark/sql/TiContext.scala +++ b/core/src/main/scala/org/apache/spark/sql/TiContext.scala @@ -43,7 +43,7 @@ class TiContext(val sparkSession: SparkSession, options: Option[TiDBOptions] = N lazy val sqlContext: SQLContext = sparkSession.sqlContext val conf: SparkConf = mergeWithDataSourceConfig(sparkSession.sparkContext.conf, options) val tiConf: TiConfiguration = TiUtil.sparkConfToTiConf(conf) - val tiSession: TiSession = TiSession.getInstance(tiConf, true) + val tiSession: TiSession = TiSession.getInstance(tiConf) val meta: MetaManager = new MetaManager(tiSession.getCatalog) StatisticsManager.initStatisticsManager(tiSession) diff --git a/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java b/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java index 678eff07b3..2efa1a80f3 100644 --- a/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java +++ b/tikv-client/src/main/java/com/pingcap/tikv/TiSession.java @@ -45,10 +45,10 @@ public class TiSession implements AutoCloseable { private static final Map sessionCachedMap = new HashMap<>(); - public static TiSession getInstance(TiConfiguration conf, boolean recreate) { + public static TiSession getInstance(TiConfiguration conf) { synchronized (sessionCachedMap) { String key = conf.getPdAddrsString(); - if (sessionCachedMap.containsKey(key) && !recreate) { + if (sessionCachedMap.containsKey(key)) { return sessionCachedMap.get(key); } @@ -58,12 +58,6 @@ public static TiSession getInstance(TiConfiguration conf, boolean recreate) { } } - // Since we create session as singleton now, configuration change will not - // reflect change - public static TiSession getInstance(TiConfiguration conf) { - return getInstance(conf, false); - } - private TiSession(TiConfiguration conf) { this.conf = conf; this.channelFactory = new ChannelFactory(conf.getMaxFrameSize());