Closed DaveMuirhead closed 5 years ago
Btw, the reason that I wanted to do this is b/c I am seeing errors (even when all test cases pass) that indicate that there are times when the delegate's jdbc connection is closed but the redispatch actor is still trying to senddelegate.confirmDispatched
and delegate.allUnconfirmedDispatchableStates
.
I did override Actor.stop
in JDBCStateStoreActor
to immediately call stop
on the JDBCRedispatchControlActor
, which in turn calls cancel
on the Cancellable
. I also adjusted the tearDown
method in JDBCTextStateStoreActorTest
to call world.stop
before delegate.close
. Neither of those adjustments prevents at least some cases where the redispatcher tries to use the delegate after its connection is closed.
I am open to other suggestions.
The errors only appear to happen when running io.vlingo.symbio.store.state.jdbc.postgres.PostgresJDBCTextStateStoreActorTest
and they will look something like:
vlingo/actors: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:767)
at org.postgresql.jdbc.PgConnection.rollback(PgConnection.java:774)
at io.vlingo.symbio.store.state.jdbc.JDBCStorageDelegate.fail(JDBCStorageDelegate.java:173)
at io.vlingo.symbio.store.state.jdbc.JDBCStorageDelegate.confirmDispatched(JDBCStorageDelegate.java:137)
at io.vlingo.symbio.store.state.jdbc.JDBCRedispatchControlActor.confirmDispatched(JDBCRedispatchControlActor.java:50)
at io.vlingo.symbio.store.state.StateStoreDispatcherControl__Proxy.lambda$confirmDispatched$1(StateStoreDispatcherControl__Proxy.java:40)
at io.vlingo.actors.LocalMessage.internalDeliver(LocalMessage.java:116)
at io.vlingo.actors.LocalMessage.deliver(LocalMessage.java:49)
at io.vlingo.actors.plugin.mailbox.concurrentqueue.ConcurrentQueueMailbox.run(ConcurrentQueueMailbox.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
or like this:
vlingo/actors: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:332)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118)
at io.vlingo.symbio.store.state.jdbc.JDBCStorageDelegate.allUnconfirmedDispatchableStates(JDBCStorageDelegate.java:65)
at io.vlingo.symbio.store.state.jdbc.JDBCRedispatchControlActor.dispatchUnconfirmed(JDBCRedispatchControlActor.java:58)
at io.vlingo.symbio.store.state.StateStoreDispatcherControl__Proxy.lambda$dispatchUnconfirmed$0(StateStoreDispatcherControl__Proxy.java:31)
at io.vlingo.actors.LocalMessage.internalDeliver(LocalMessage.java:116)
at io.vlingo.actors.LocalMessage.deliver(LocalMessage.java:49)
at io.vlingo.actors.plugin.mailbox.concurrentqueue.ConcurrentQueueMailbox.run(ConcurrentQueueMailbox.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
at org.postgresql.core.PGStream.receiveChar(PGStream.java:293)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1947)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
... 13 more
@VaughnVernon I propose adding isClosed to
StorageDelegate
so thatJDBCRedispatchControlActor
can guard against closed connections before it callsdelegate.confirmDispatched
ordelegate.allUnconfirmedDispatchableStates
. The alternative is for the delegate itself to be responsible for guarding against closed connections in those (and probably other) methods