Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

Resource leak in MarkLogicRepository #47

Open
tdiepenbrock opened this issue Feb 28, 2019 · 1 comment
Open

Resource leak in MarkLogicRepository #47

tdiepenbrock opened this issue Feb 28, 2019 · 1 comment
Assignees
Labels

Comments

@tdiepenbrock
Copy link

From client:

I have identified what looks like a substantial resource leak in the MarkLogicRepository class (part of the Marklogic-rdf4j code).

I’m using the databaseClient constructor (MarkLogicRepository:170), which sets the databaseClient, securityContext and client attributes in the constructor based on the passed-in databaseClient.
As part of the setup process, initialize() is then called, which calls initializeInternal (markLogicRepository:208) which basically does nothing as everything is already set.
At various points, getConnection (MarkLogicRepository:284) is called, which on line 289 ALWAYS calls getMarkLogicClient.
getMarkLogicClient (MarkLogicRepository:299) ALWAYS creates a new DatabaseClient instance and corresponding MarkLogicClient instance rather than using the instances set in the constructor.

I think this is a resource leak because DatabaseClient instances need to be released when we’re done with them, and by constantly overwriting a DatabaseClient instance, the code does not do that.

I suspected a possible resource leak when I noticed that my main() program doesn’t terminate when run in eclipse, it just hangs forever even after completing all the application cleanup scripts. The debugger reveals that numerous databaseClient-related threads are still running, even though the cleanup code properly calls MarkLogicRepository.shutdown, which ought to clean up the DatabaseClient.

While I can’t be sure this is the cause, the getMarkLogicClient code looks very suspicious to me. Why doesn’t it just return this.client? All the constructors appear to initialize it properly (with the help of initialize()) so it shouldn’t need to be overwritten with every call to getConnection, should it?

@ehennum ehennum self-assigned this Feb 28, 2019
@ehennum ehennum added the bug label Feb 28, 2019
@ehennum ehennum assigned georgeajit and unassigned ehennum Mar 22, 2019
@ehennum
Copy link

ehennum commented Mar 22, 2019

should not cause any regressions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants