[IOTDB-1148]fix the client leak of client pool&use remote schema cache when check timeseries exist or not#2635
Conversation
cluster/src/main/java/org/apache/iotdb/cluster/query/reader/RemoteSeriesReaderByTimestamp.java
Show resolved
Hide resolved
cluster/src/main/java/org/apache/iotdb/cluster/query/reader/RemoteSimpleSeriesReader.java
Outdated
Show resolved
Hide resolved
|
SonarCloud Quality Gate failed. |
tsfile/src/main/java/org/apache/iotdb/tsfile/utils/PublicBAOS.java
Outdated
Show resolved
Hide resolved
tsfile/src/main/java/org/apache/iotdb/tsfile/utils/PublicBAOS.java
Outdated
Show resolved
Hide resolved
|
Generally, the connection pool is used to obtain connections from the connection pool. After the close connection is used, the close connection only puts the connection back to the connection pool. The connection pool maintains the lifecycle of the connection. |
Actually, it's not exactly right. Not all client life cycles are processed in the client pool. When getting a client for remote process use, there may be problems. For example, a client may fail to connect due to network delay or server downtime. At this time, we need to close the connection. When you put the client in the client pool, if you find that the connection is closed, you will not put it in the pool. The role of the client pool is to save some clients that have created connections. When you want to connect to a server, you don't need to create connections again, which saves the overhead of creating and closing connections frequently. |
| public synchronized boolean containsKey(PartialPath key) { | ||
| return cache.containsKey(key); | ||
| } |
There was a problem hiding this comment.
Is it necessary to mix synchronized and lock?
There was a problem hiding this comment.
Since all methods in RemoteMetaCache are synchronized, it is safe to modify the cache. However, in CMManager, functions in RemoteMetaCache may be called many times in a function, which may be due to the serialization of cache operations in CMManager, so the lock is added?
Therefore, I think in CMManager, whether the cache operation is locked or not is OK. Locking can ensure that all cache operations in CMManager are serial. However, since RemoteMetaCache itself is thread-safe, maybe it's also OK not to lock it.
61e07c3 to
c79f8ef
Compare
for more details, please see https://issues.apache.org/jira/browse/IOTDB-1148