IBMStockTrader/portfolio

Concurrent Delete

rtclauss opened this issue · 1 comments

Was seeing the following error in portfolio

WTRN0074E: Exception caught from before_completion synchronization operation: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.10.v20211216-fe64cd39c3): org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: org.postgresql.util.PSQLException: ERROR: could not serialize access due to concurrent delete\nError Code: 0\nCall: DELETE FROM STOCK WHERE ((SYMBOL = ?) AND (owner = ?))\n\tbind => [2 parameters bound]\nQuery: DeleteObjectQuery({\"symbol\": \"AMZN\", \"shares\": 5, \"commission\": 9.99, \"price\": 140.8, \"total\": 704.0, \"date\": \"2022-08-05\"})\n\tat org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl$1.handleException(EntityManagerSetupImpl.java:788)\n\tat

Googling led to this answer
https://stackoverflow.com/questions/38466095/in-a-was-liberty-connection-pool-can-i-validate-connections-on-borrow

So the connection pool should be:

<connectionManager id="dbConnections" maxPoolSize="50" purgePolicy="ValidateAllConnections" validationTimeout="10m"/>

I've been running this for 2 months now without seeing any more concurrent delete errors in portfolio.

Fixed under 4067e0c