telefonicaid / fiware-keypass

Keypass is a multitenant XACML Authorization Server (Access Control) with PAP (Policy Administration Point) and PDP (Policy Decision Point) capabilities used by IoT Platform.
Apache License 2.0
9 stars 5 forks source link

When occurs a communications failure then not reconnect #116

Closed cesarjorgemartinez closed 4 years ago

cesarjorgemartinez commented 5 years ago

When a communications failure, the keypass process not try to reconnect (logs below):

Also, we need to manage logs (error conditions and release conditions to alarm logs of keypass.

zcat keypass-2019-01-27.log.gz
time=2019-01-26T23:01:28.094Z | lvl=ERROR | comp=KEYPASS | corr=e8bc50a4-dc2b-4d47-9d3d-c4de42518ead | trans=n/a | srv=thinkingcity | op=SqlExceptionHelper | msg=Communications link failure

Last packet sent to the server was 0 ms ago.
time=2019-01-26T23:01:28.162Z | lvl=ERROR | comp=KEYPASS | corr=e8bc50a4-dc2b-4d47-9d3d-c4de42518ead | trans=n/a | srv=thinkingcity | op=LoggingExceptionMapper | msg=Error handling a request: a296cdc7da11278d
org.hibernate.exception.JDBCConnectionException: could not extract ResultSet
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:89) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.getResultSet(Loader.java:2065) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.doQuery(Loader.java:909) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.doList(Loader.java:2553) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.doList(Loader.java:2539) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.Loader.list(Loader.java:2364) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:126) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1682) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380) ~[keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.hibernate.AbstractDAO.list(AbstractDAO.java:107) ~[keypass.jar:1.3.0-0.g818f297]
at es.tid.fiware.iot.ac.dao.PolicyDAOHibernate.getPolicies(PolicyDAOHibernate.java:60) ~[keypass.jar:1.3.0-0.g818f297]
at es.tid.fiware.iot.ac.pdp.PdpFactoryCached.toPolicy(PdpFactoryCached.java:85) ~[keypass.jar:1.3.0-0.g818f297]
at es.tid.fiware.iot.ac.pdp.PdpFactoryCached.get(PdpFactoryCached.java:71) ~[keypass.jar:1.3.0-0.g818f297]
at es.tid.fiware.iot.ac.pdp.PdpEndpoint.enforce(PdpEndpoint.java:77) ~[keypass.jar:1.3.0-0.g818f297]
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[keypass.jar:1.3.0-0.g818f297]
at com.codahale.metrics.jersey.InstrumentedResourceMethodDispatchProvider$TimedRequestDispatcher.dispatch(InstrumentedResourceMethodDispatchProvider.java:30) ~[keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.hibernate.UnitOfWorkRequestDispatcher.dispatch(UnitOfWorkRequestDispatcher.java:43) ~[keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jersey.guava.OptionalResourceMethodDispatchAdapter$OptionalRequestDispatcher.dispatch(OptionalResourceMethodDispatchAdapter.java:37) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.uri.rules.ResourceObjectRule.accept(ResourceObjectRule.java:100) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) ~[keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540) [keypass.jar:1.3.0-0.g818f297]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715) [keypass.jar:1.3.0-0.g818f297]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jetty.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1515) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:295) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jetty.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:127) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1486) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.servlets.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1486) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jersey.filter.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:44) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jersey.filter.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:39) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1486) [keypass.jar:1.3.0-0.g818f297]
at es.tid.fiware.iot.ac.MDCFilter.doFilter(MDCFilter.java:48) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1486) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:519) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1097) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:448) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1031) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [keypass.jar:1.3.0-0.g818f297]
at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:175) [keypass.jar:1.3.0-0.g818f297]
at io.dropwizard.jetty.RoutingHandler.handle(RoutingHandler.java:51) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:92) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:162) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.Server.handle(Server.java:446) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:271) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:246) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601) [keypass.jar:1.3.0-0.g818f297]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532) [keypass.jar:1.3.0-0.g818f297]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_191]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_191]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885) ~[keypass.jar:1.3.0-0.g818f297]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80) ~[keypass.jar:1.3.0-0.g818f297]
... 71 common frames omitted
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_191]
at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_191]
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428) ~[keypass.jar:1.3.0-0.g818f297]
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882) ~[keypass.jar:1.3.0-0.g818f297]
... 79 common frames omitted
time=2019-01-26T23:01:28.167Z | lvl=ERROR | comp=KEYPASS | corr=e8bc50a4-dc2b-4d47-9d3d-c4de42518ead | trans=n/a | srv=thinkingcity | op=ContainerResponse | msg=A message body writer for Java class io.dropwizard.jersey.errors.ErrorMessage, and Java type class io.dropwizard.jersey.errors.ErrorMessage, and MIME media type application/xml was not found.
The registered message body writers compatible with the MIME media type are:
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
application/xml ->
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App
fgalan commented 4 years ago

Fixed by PR https://github.com/telefonicaid/fiware-keypass/pull/130