Skip to content

Removed finalize from NetworkSession #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2016

Conversation

lutovich
Copy link
Contributor

It contained logic for closing opened underlying connection and logging info about the leak. Closing of resources in finalize is not reliable and overridden finalize can hurt when many sessions are garbage collected.

Commit also introduces a system property org.neo4j.driver.logSessionLeaks to enable logging of unclosed/leaked sessions and log stacktrace of where they were instantiated. This is meant to help with session leak investigations. So finalization overhead will be present only when problem is present and is being investigated.

{
if ( isOpen() )
{
log.error( "Neo4j Session object leaked, please ensure that your application" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error? or info? or warn?
These three are all printed out by default in command line logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leak is basically an error, that is why I use log.error here.

this.logger = logging.getLog( LOGGER_NAME );
}

public static boolean leakLoggingEnabled()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if we should enable it by a system variable or by a config option?
Such as
Driver driver = Graphdatabase.Driver(uri, auth, Config.build().withSessionLeakLoggingEnabled().toConfig())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main motivation for using system property is that users would not need to recompile their apps for leak investigation. So it would be possible to just restart it with -Dorg.neo4j.driver.logSessionLeaks=true. Do you think this makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, that's good thinking. I was just thinking that they need to restart anyway, but yeah, if they do not need to change the code, that's even better

@lutovich lutovich force-pushed the 1.1-remove-finalize branch from bcd8bab to b72e04c Compare December 1, 2016 10:08
@zhenlineo
Copy link
Contributor

You need to update your file header

@zhenlineo
Copy link
Contributor

@lutovich Sorry, need to rebase. I am general +1 on this, while I am wondering if we want to add this special parameter as a system property or we should consider to add in Config and build a xml config reader

It contained logic for closing opened underlying connection and logging info
about the leak. Closing of resources in finalize is not reliable and overridden
finalize can hurt when many sessions are garbage collected.

Commit also introduces a system property `org.neo4j.driver.logSessionLeaks`
to enable logging of unclosed/leaked sessions and log stacktrace of where they
were instantiated. This is meant to help with session leak investigations. So
finalization overhead will be present only when problem is present and is
being investigated.
It was previously in system property. This commit makes it part of `Config` so
we have a single place with all configuration parameters.
@lutovich lutovich force-pushed the 1.1-remove-finalize branch from 4517bc1 to b0ce429 Compare December 12, 2016 14:03
@zhenlineo zhenlineo merged commit 5de9312 into neo4j:1.1 Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants