You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Jason Gerlowski (Jira)" <ji...@apache.org> on 2020/07/22 14:43:00 UTC

[jira] [Comment Edited] (SOLR-14677) DIH doesnt close JdbcDataSource when import encounters errors

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

Jason Gerlowski edited comment on SOLR-14677 at 7/22/20, 2:42 PM:
------------------------------------------------------------------

I have a branch [here|https://github.com/gerlowskija/lucene-solr-1/tree/jdbcdatasource_connection_leak] with a few edits that help reproduce the problem.

What that branch has is:
* logging in JdbcDataSource.close() to record if/when it is called.
* a script "solr/reproduce-dih-jdbc-leak.sh", which can be run from in the solr directory to reproduce the problem.
* some changes to ConcurrentUpdateHttp2SolrClient which optionally fake an IOException to trigger the DIH issue downstream.

To reproduce the issue, run the included script from the "solr" directory.  It spins up two solr nodes based out of a "cloud-dih" example directory, and kicks off a DIH run.  When the DIH run finishes, the logs (in {{solr/example/cloud-dih/node1/logs/solr.log}}) will be missing the line that gets printed when JdbcDataSource closes: {{In JdbcDataSource.close}}.

To see the "normal" behavior, edit the "reproduce-dih-jdbc-leak.sh" script, changing the {{CAUSE_DIH_IO_ERROR}} variable from "true" to "false".  Following a DIH run, the logs will show that JdbcDataSource was closed correctly.

For the lazy, I've attached the log file from the DIH node from two runs: one that shows the normal good behavior and one that shows the leak when an IOError pops up during the import.


was (Author: gerlowskija):
I have a branch [here|https://github.com/gerlowskija/lucene-solr-1/tree/jdbcdatasource_connection_leak] with a few edits that help reproduce the problem.

What that branch has is:
* logging in JdbcDataSource.close() to record if/when it is called.
* a script "solr/reproduce-dih-jdbc-leak.sh", which can be run from in the solr directory to reproduce the problem.
* some changes to ConcurrentUpdateHttp2SolrClient which optionally fake an IOException to trigger the DIH issue downstream.

To reproduce the issue, run the included script from the "solr" directory.  It spins up two solr nodes based out of a "cloud-dih" example directory, and kicks off a DIH run.  When the DIH run finishes, the logs (in {{solr/example/cloud-dih/node1/logs/solr.log}}) will be missing the line that gets printed when JdbcDataSource closes: {{In JdbcDataSource.close}}.

To see the "normal" behavior, edit the "reproduce-dih-jdbc-leak.sh" script, changing the {{CAUSE_DIH_IO_ERROR}} variable from "true" to "false".  Following a DIH run, the logs will show that JdbcDataSource was closed correctly.

> DIH doesnt close JdbcDataSource when import encounters errors
> -------------------------------------------------------------
>
>                 Key: SOLR-14677
>                 URL: https://issues.apache.org/jira/browse/SOLR-14677
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: contrib - DataImportHandler
>    Affects Versions: 7.5, master (9.0)
>            Reporter: Jason Gerlowski
>            Priority: Minor
>         Attachments: error-solr.log, no-error-solr.log
>
>
> DIH imports don't close DataSource's (which can hold db connections, etc.) in all cases.  Specifically, if an import runs into an unexpected error forwarding processed docs to other nodes, it will neglect to close the DataSource's when it finishes.
> This problem goes back to at least 7.5.  This is partially mitigated in older versions of some DataSource implementations (e.g. JdbcDataSource) by means of a "finalize" hook which invokes "close()" when the DataSource object is garbage-collected.  In practice, this means that resources might be held open longer than necessary but will be closed within a few seconds or minutes by GC.  This only helps JdbcDataSource though - all other DataSource impl's risk leaking resources. 
> In master/9.0, which requires a minimum of Java 11 and doesn't have the finalize-hook, the connections are never cleaned up when an error is encountered during DIH.  DIH will likely be removed for the 9.0 release, but if it isn't this bug should be fixed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org