• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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: 22503
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.
Posts: 1945
  • 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 ?
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic