[ 
https://issues.apache.org/jira/browse/IGNITE-5382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114398#comment-16114398
 ] 

Vladimir Ozerov commented on IGNITE-5382:
-----------------------------------------

[~skalashnikov], IMO this approach is prone to leaks. We have N threads, M 
connection, and K statements. Only K is under our control at the moment. The 
rest things can cause memory leaks if many client threads are used, and even 
periodic cleanup would not help us. 

May be would be better to merge both connections and statements as follows 
(pseudocode):

1) Thread local statement cache
{code}
ThreadLocal<Cache> cache;
{code}

2) Cache contains active connections with usage counters, and 
Statement/Connection pairs:
{code}
class Cache {
    Map<String, T2<Connection, Integer>> conns; // Map from schema name to 
connection/counter.
    Map<T2<String, String>, T2<Connection, PreparedStatement>>; // Bounded map 
from schema/SQL to connection/statement.
}
{code}

This way we will have N threads and K statement/connection pairs, which is more 
predictable.

Thoughts?

> SQL: frequent switch between schemas cause severe slowdown
> ----------------------------------------------------------
>
>                 Key: IGNITE-5382
>                 URL: https://issues.apache.org/jira/browse/IGNITE-5382
>             Project: Ignite
>          Issue Type: Task
>          Components: cache, sql
>            Reporter: Vladimir Ozerov
>            Assignee: Sergey Kalashnikov
>              Labels: important, performance
>             Fix For: 2.2
>
>
> We have thread-bound cached connection to H2 database which is bound to 
> specific schema. See {{IgniteH2Indexing.connectionForThread}}.
> When query with different schema is executed, we call {{SET SCHEMA}} command, 
> which is rather expensive and may cause slowdown when queries form different 
> caches are executed.
> To avoid this we should maintain thread-local map of such connections. Be 
> careful with concurrency and resource leaks.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to