[ 
https://issues.apache.org/jira/browse/CALCITE-6517?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-6517:
---------------------------------
    Component/s: mongodb-adapter

> “calcite-mongodb” can not close MongoClient,  and thread will be leaked
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-6517
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6517
>             Project: Calcite
>          Issue Type: Improvement
>          Components: mongodb-adapter
>            Reporter: Dirk Zhou
>            Priority: Minor
>         Attachments: image-2024-08-06-16-27-11-691.png
>
>
> in my code :
>  
> {code:java}
> Schema schema = new MongoSchemaFactory().create(rootSchema, "schema1", 
> config);
> calciteConn.getRootSchema().add( "schema1", schema);
> {code}
>  
> calciteConn is {*}org.apache.calcite.jdbc.CalciteConnection{*}.
> *MongoSchemaFactory* will create *MongoSchema*
> when calciteConn.close(),  the *MongoClient* created in 
> "{*}org.apache.calcite.adapter.mongodb.MongoSchema{*}" is not closed, the 
> thread of "{*}com.mongodb.internal.connection.DefaultServerMonitor{*}" will 
> be leaked.
> {color:#4c9aff}*_My advice:_*{color}
> The local variable *“mongo”* is modified to be a *instance variable* ,and 
> provide getter. This way, when close {*}CalciteConnection{*}, also get 
> *MongoClient* and close it.
> *!image-2024-08-06-16-27-11-691.png|width=978,height=521!*



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to