You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are currently using OrientDB version 3.1.16 for our Production Project. There are 6-7 Spring Boot applications which involve in various read and write operations on database.
For every API call, check if connections are available from Graph Factory Pool, if present then get the connection else establish a new connection to Database and perform the required operation.
Actual behavior
The session established by an API call is not getting closed or released back to Graph pool factory due to which we are not able to establish new connection after some point of time.
Steps to reproduce
Following is sample code being used:
OrientDB Connection class
public class OrientDBConnection {
/**
logger.info("graph from pool factory is created");
} catch (Exception ex) {
logger.info("Cannot create Graph from pool factory with exception {}", ex);
}
return graph;
}
}
Service Layer
public class SampleServiceLayer
{
/* Establish DB connection */
OrientGraph checkConnection() {
OrientGraph graph = dbConnection.createGraphConnection();
return graph;
}
// sample function
public List getSampleList() {
List result = new ArrayList();
Since we are already in Production mode, this issue has become extremely critical to us.
Request you to provide feedback at earliest.
Also, with reference to the above code - is it the correct way to connect to Orient Database? Any reference on how to connect to database from Java application would be really helpful.
The text was updated successfully, but these errors were encountered:
ChaitraSatish
changed the title
Close DB Sessions from Spring Boot application to avoid reaching limit of max DB sessions
Close DB Sessions in Spring Boot application to avoid reaching limit of max DB sessions
Nov 22, 2023
OrientDB Version: 3.1.16
Java Version: 1.8
OS: Linux
Expected behavior
We are currently using OrientDB version 3.1.16 for our Production Project. There are 6-7 Spring Boot applications which involve in various read and write operations on database.
For every API call, check if connections are available from Graph Factory Pool, if present then get the connection else establish a new connection to Database and perform the required operation.
Actual behavior
The session established by an API call is not getting closed or released back to Graph pool factory due to which we are not able to establish new connection after some point of time.
Steps to reproduce
Following is sample code being used:
OrientDB Connection class
public class OrientDBConnection {
/**
*/
protected OrientGraphFactory getConnectionPool() {
if(poolFactory == null) {
poolFactory = createConnPool();
}
return poolFactory;
}
/**
/
protected OrientGraphFactory createConnPool() {
logger.info("Creating DB connection pool");
String dbUrl= AppConfigProperties.getConfigValue("orientDB.url");
poolFactory = new OrientGraphFactory(dbUrl).setupPool(1, 500);
poolFactory.setProperty("password", "***");
poolFactory.setProperty("username", "**");
return poolFactory;
}
/**
Acquires pool from poolFactory and
established graph connection
@return Graph
*/
public OrientGraph createGraphConnection() {
OrientGraph graph = null;
try {
if (poolFactory == null) {
poolFactory = createConnPool();
}
graph = poolFactory.getTx();
} catch (Exception ex) {
logger.info("Cannot create Graph from pool factory with exception {}", ex);
}
return graph;
}
}
Service Layer
public class SampleServiceLayer
{
/* Establish DB connection */
OrientGraph checkConnection() {
OrientGraph graph = dbConnection.createGraphConnection();
return graph;
}
// sample function
public List getSampleList() {
List result = new ArrayList();
}
}
Since we are already in Production mode, this issue has become extremely critical to us.
Request you to provide feedback at earliest.
Also, with reference to the above code - is it the correct way to connect to Orient Database? Any reference on how to connect to database from Java application would be really helpful.
The text was updated successfully, but these errors were encountered: