• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Connection leak help needed...

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a spring boot rest API utilizing 2 datasources.  The one datasource keeps leaking connections and the active amount just keeps increasing over time until it reaches its' max and then the client cannot get a connection afterwards.  When I run this from my local eclipse install under a similar load, I can see from the trace that the connections are being returned and they never increase over single digits so I don't see the connection leak.  However, when this is deployed to a docker container utilizing nginx as a reverse proxy, it consistently leaks the connections no matter what configurations I give it.  I am using the most recent version of Hikari.  Can this be a potential issue with the docker container holding connections for some reason?  Any help would be great.

Saloon Keeper
Posts: 22126
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at your connection pool definition. You should have an option to track leaks. It works by taking a stack snapshot when you pull a Connection from the pool, and printing out the snapshot if the Connection has not been returned within a set amount of time. Knowing where you got the Connection can usually help you figure out where it's being used and where it might be getting lost. And if the path over which it's being used is too long and convoluted to follow, that in itself is a signal of probable poor design. Better to get a Connection and give it back repeatedly than to hoard it. Checking a Connection in and out of the Connection pool is a very low-overhead thing to do.

Incidentally, Spring Data, when properly used, leak-proofs Connections.
Ranch Foreman
Posts: 1903
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg,
Did you close the entity manager or DB connection every time you finish one commit ?
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic