우리는 MySQL 데이터베이스에서 우리의 다른 응용 프로그램에 위치 관련 정보를 제공하는 위치 서비스 응용 프로그램을 가지고 있습니다. 몇 가지 이유로 인해 위치 서비스가 여러 요청을 수신 할 때 MySQL 데이터베이스에 연결하지 못합니다. 우리는 지속적으로 15-20 개의 요청을 동시에받을 때 오류가 있음을 확인했습니다. 다음 스 니펫은 MySQL 구성 코드 및 오류 스택입니다.Hikari CP 연결 오류
[email protected](name = "locationDataSource")
public HikariDataSource getDataSource(@Value("${projectxx.mysql.location.url}") String url,
@Value("${projectxx.mysql.location.username}") String username,
@Value("${projectxx.mysql.location.password}") String password) {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(url);
config.setUsername(username);
config.setPassword(password);
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setMaximumPoolSize(45);
config.setPoolName("locationDBpool");
config.setMinimumIdle(15);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return new HikariDataSource(config);
}
@Bean(name = "locationSession")
@Qualifier("locationDataSource")
public SessionFactory getSessionFactoryBean(@Autowired(required = true) HikariDataSource dataSource) {
LocalSessionFactoryBean sessionFacBean = new LocalSessionFactoryBean();
sessionFacBean.setDataSource(dataSource);
sessionFacBean.setPackagesToScan("com.projectxxx.dao");
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
sessionFacBean.setHibernateProperties(hibernateProperties);
try {
sessionFacBean.afterPropertiesSet();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sessionFacBean.getObject();
}
java.sql.SQLTransientConnectionException : locationDBpool - 연결을 사용할 수없는, 요청이 30000ms 후 시간이 초과되었습니다. at com.zaxxer.hikari.pool.HikariPool.createTimeoutException (HikariPool.java:666) ~ [HikariCP-2.7.4.jar : na] at com.zaxxer.hikari.pool.HikariPool.getConnection (HikariPool.java : 182) ~ [HikariCP-2.7.4.jar : na] com.zaxxer.hikari.pool.HikariPool.getConnection (HikariPool.java:147) ~ [HikariCP-2.7.4.jar : na] at com. getConnection (HikariDataSource.java:85) ~ [HikariCP-2.7.4.jar : na] at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection (DatasourceConnectionProviderImpl.java:122)에서 zaxxer.hikari.HikariDataSource.getConnection ~ ~ [hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.internal.AbstractSessionImpl $ NonContextualJdbcConnectionAccess.obtainConnection (AbstractSessionImpl.java:386) ~ [hibernate-core-5.0.12. Final.jar : 5.0.12. 최종] at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded (LogicalConnectionManagedImpl.java:87) ~ [hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.resource.jdbc. internal.LogicalConnectionManagedImpl.getPhysicalConnection (LogicalConnectionManagedImpl.java:112) ~ [hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getConnectionForTransactionManagement (LogicalConnectionManagedImpl. java : 230) ~ [hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.begin (LogicalConnectionManagedImpl.java:237) ~ [hibernate- core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl $ TransactionDriverControlImpl.begin (JdbcResourceLocal TransactionCoordinatorImpl.java:214) ~ [hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.engine.transaction.internal.TransactionImpl.begin (TransactionImpl.java:52) ~ [ hibernate-core-5.0.12.Final.jar : 5.0.12.Final] at org.hibernate.internal.SessionImpl.beginTransaction (SessionImpl.java:1512) ~ [hibernate-core-5.0.12.Final.jar : 5.0.12. 최종] at com.projectxxx.actionImpl.LocationManagementImpl.findAddressByPostalCode (LocationManagementImpl.java:40) ~ [classes/: na] at com.projectxxx.controller.LocationReadController.service3 (LocationReadController.java:40) ~ [클래스/: NA] sun.reflect.GeneratedMethodAccessor51.invoke (알 소스)에 ~ [NA : NA] sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)에서 ~ [NA : 1.8.0_131] at java.l (InvocableHandlerMethod.java:205) ~ [spring-web-web.news] [웹 서비스] [웹 서비스] [웹 서비스] 4.3.12.RELEASE.jar : 4.3.12.RELEASE] org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest (InvocableHandlerMethod.java:133) ~ [spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod.java:97) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12. RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod (RequestMappingHandlerAdapter.java:827) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappi ngHandlerAdapter.handleInternal (RequestMappingHandlerAdapter.java:738) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter.java:85) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3. 12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:967) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework. web.servlet.DispatcherServlet.doService (DispatcherServlet.java:901) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet. java : 970) ~ [spring-webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:861) ~ [spring-webmvc- 4.3.12.RELEASE.jar : 4.3.12.RELEASE] (javax.servlet.http.HttpServlet.ser) (org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846) ~ [spring-embed-core-8.5.23.jar : 8.5.23] ) webmvc-4.3.12.RELEASE.jar : 4.3.12.RELEASE] 에서 javax.servlet.http.HttpServlet.service (HttpServlet.java:742) ~ [tomcat-embed-core-8.5.23.jar : 8.5. 23] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:231) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core. ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) ~ [tomcat-embed-websocket-8.5.23.jar : 8.5.23] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [to : mcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter.java:99) ~ [spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.)에서 . java : 193) ~ [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core- 8.5.23.jar : 8.5.23] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInt (HelperPutFormContentFilter.java:108) ~ [spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) ~ [ spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] 에서 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [tomcat-embed-core-8.5.23. jar : 8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.springframework. Web.filter.HiddenHttpMethodFilter.doFilterInternal (HiddenHttpMethodFilter.java:81) ~ [spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java : 107) ~ [spring-web-4.3.12.RELEASE.jar : 4.3.12.RELEASE] a org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter.java:197) ~ [spring-web -4.3.12.RELEASE.jar : 4.3.12.RELEASE] org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) ~ [spring-web-4.3.12.RELEASE.jar : 4.3 .12.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:193) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina .core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:166) ~ [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:199) ~ [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache. org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:478)에서 [표준 컨테이너 컨텍스트]) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:140) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:81) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catalina. core.StandardEngineValve.invoke (StandardEngineValve.java:87) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.catali na.connector.CoyoteAdapter.service (CoyoteAdapter.java:342) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.coyote.http11.Http11Processor.service (Http11Processor.java:803)) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.coyote.AbstractProcessorLight.process (AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.23.jar : 8.5 .23] at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol.java:868) [tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.tomcat.util. net.NioEndpoint $ SocketProcessor.doRun (NioEndpoint.java:1459) [Tomcat-embed-core-8.5.23.jar : 8.5.23] at org.apache.tomcat.util.net.SocketProcessorBase.run (SocketProcessorBase.java) : 49) [tomcat-embed-core-8.5.23.jar : 8.5.23] at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142) [없음 : 1.8.0] (ThreadPoolExecutor.java:617) [na : 1.8.0_131] 에서 org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread.java) 61) 톰캣 - 포함 코어-8.5.23.jar : 8.5.23] java.lang.Thread.run (Thread.java:748에서 ) NA : 1.8.0_131]
try setMaximumPoolSize (100); – user7294900
안녕하세요 @ user7294900, 다른 이유로 인해 풀 크기를 변경할 수 없습니다. 당신이 나에게 그걸 설명 할 수 있다면 정말 고마워요? –