我用的PostgreSQL 9.3和5.2的Liferaycom.liferay.portal.kernel.job.JobExecutionException:org.postgresql.util.PSQLException:這個連接已經關閉
系統工作正常,但一段時間後,我有我在日誌文件中有連接丟失問題。
(org.springframework.scheduling.quartz.SchedulerFactoryBean#6e2243fb_Worker-2) 07:19:09,914 ERROR [JobWrapper:81] com.liferay.portal.kernel.job.JobExecutionException: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
com.liferay.portal.kernel.job.JobExecutionException: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.execute(ConnectionHeartbeatJob.java:55)
at com.liferay.portal.job.JobWrapper.execute(JobWrapper.java:69)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Caused by: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:226)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:321)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:313)
at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.sendHeartbeat(ConnectionHeartbeatJob.java:75)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.execute(ConnectionHeartbeatJob.java:52)
... 3 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:70)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:283)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1799)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
... 9 more
2017-08-13 08:19:09,901 INFO [STDOUT] (org.springframework.scheduling.quartz.SchedulerFactoryBean#6e2243fb_Worker-1) 08:19:09,901 WARN [NewPooledConnection:486] [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
2017-08-13 08:19:09,903 INFO [STDOUT] (org.springframework.scheduling.quartz.SchedulerFactoryBean#6e2243fb_Worker-1) 08:19:09,902 WARN [NewPooledConnection:487] [c3p0] Another error has occurred [ org.postgresql.util.PSQLException: This connection has been closed. ] which will not be reported to listeners!
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:786)
at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:1598)
at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:405)
at com.mchange.v2.c3p0.impl.NewProxyConnection.createStatement(NewProxyConnection.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:364)
at com.sun.proxy.$Proxy261.createStatement(Unknown Source)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.sendHeartbeat(ConnectionHeartbeatJob.java:73)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.execute(ConnectionHeartbeatJob.java:52)
at com.liferay.portal.job.JobWrapper.execute(JobWrapper.java:69)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
2017-08-13 08:19:09,905 INFO [STDOUT] (org.springframework.scheduling.quartz.SchedulerFactoryBean#6e2243fb_Worker-1) 08:19:09,903 ERROR [JobWrapper:81] com.liferay.portal.kernel.job.JobExecutionException: org.postgresql.util.PSQLException: This connection has been closed.
com.liferay.portal.kernel.job.JobExecutionException: org.postgresql.util.PSQLException: This connection has been closed.
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.execute(ConnectionHeartbeatJob.java:55)
at com.liferay.portal.job.JobWrapper.execute(JobWrapper.java:69)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:786)
at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:1598)
at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:405)
at com.mchange.v2.c3p0.impl.NewProxyConnection.createStatement(NewProxyConnection.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:364)
at com.sun.proxy.$Proxy261.createStatement(Unknown Source)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.sendHeartbeat(ConnectionHeartbeatJob.java:73)
at com.liferay.counter.service.persistence.ConnectionHeartbeatJob.execute(ConnectionHeartbeatJob.java:52)
... 3 more
這是我在配置portal-ext.properties:
#
# PostgreSQL
#
jdbc.default.driverClassName=org.postgresql.Driver
jdbc.default.url=jdbc:postgresql://192.168.2.3:5432/portal
jdbc.default.username=postgres
jdbc.default.password=postgres
,我嘗試添加這些行,但錯誤依然出現:
jdbc.default.testConnectionOnCheckout=true
jdbc.default.preferredTestQuery=SELECT 1
jdbc.default.acquireIncrement=1
jdbc.default.maxIdleTime=10800
jdbc.default.maxConnectionAge=14400
jdbc.default.numHelperThreads=20
我無法理解錯誤, 可能是postgresql設置或liferay連接池設置中的問題
我此行postgresql.conf中可以改變來解決這個問題:
#synchronous_standby_names = '' # standby servers that provide sync rep
# comma-separated list of application_name
# from standby(s); '*' = all
更新時間:
顯示此錯誤日誌文件中幾次,但第一次出現是在一分鐘後可能需要1小時。
我在Docker容器中運行Postgresql。
liferay和數據庫容器在同一臺物理服務器上。
我不知道爲什麼數據庫連接在某些時候無法訪問。
這是泊塢窗版本:
docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 10 21:20:36 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 10 21:21:56 2017
OS/Arch: linux/amd64
Experimental: false
感謝您的回覆,我已經更新了我的問題,我使用了數據庫容器,我認爲postgreSQL沒有與Docker一起使用的問題,這個錯誤在日誌文件中多次顯示,但是第一次出現是在一些分鐘可能需要1個小時。 – franco