Error closing connection


#1

Hi guys,

I’m starting some experiments with Grakn using Java API.

I have included this dependencies in POM for a remote connection:

<dependency>
	<groupId>ai.grakn</groupId>
	<artifactId>grakn-graph</artifactId>
	<version>${grakn.version}</version>
</dependency>
<dependency>
	<groupId>ai.grakn</groupId>
	<artifactId>titan-factory</artifactId>
	<version>${grakn.version}</version>
	<exclusions>
		<exclusion>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-nop</artifactId>
		</exclusion>
	</exclusions>
</dependency>

So when execute this code:

GraknSession graknSession = Grakn.session(Grakn.DEFAULT_URI, "grakn");
GraknGraph graknGraph = graknSession.open(GraknTxType.WRITE);

//...

graknGraph.close();
graknSession.close();

the log shows

[main] ERROR com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager - com.netflix.MonitoredResources:type=ASTYANAX,name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
[main] ERROR com.netflix.astyanax.connectionpool.impl.ConnectionPoolMBeanManager - com.netflix.MonitoredResources:type=ASTYANAX,name=ClusterTitanConnectionPool,ServiceType=connectionpool

on close.

What am I doing wrong?

Note: i excluded nop dependency because in my project already have a binder for slf4j.

Thanks for your help.
Francesco


#2

Hi @fcioffi,

Sorry for the delayed response.

That error message is simple stating that the connection pool closed down slower than expected. This can sometimes happen on slower or congested machines. We are still trying to resolve that particular issue but it should not affect how you interact with grakn via the Java API.

Did you find it affecting you directly?

Regards,

Filipe


#3

Hi Filipe,

thanks for the response. The message appear on my pc but also, on a Cloud Server with many resources.

In a web application is correct to close graph (GraknGraph) after each commit and close session (GraknSession) at application shutdown?

I must wait for a correct close?

Thanks for your help.

Francesco


#4

Typically you will want to close the graph GraknGraph after being done with the current transaction. This is wether you are reading or writing to the graph.

You should only close the session GraknSession once you are sure you will not be touching the graph for quite some time. Closing the session basically means that you not going to read or write from/to the graph for quite some time.

If you are closing both the session and the graph after every graph operation and these operations are happening frequently then you will be slowing things down considerably. Opening a session is an expensive operation which is why you should try to keep it open when you have multiple transactions to perform on the graph.

For a typical web application you will usually open the session when initialising the app and close it when brining down the app.