Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimumIdle=0 means no limit? #115

Closed
djj0809 opened this issue Jul 21, 2014 · 4 comments
Closed

minimumIdle=0 means no limit? #115

djj0809 opened this issue Jul 21, 2014 · 4 comments
Labels

Comments

@djj0809
Copy link

djj0809 commented Jul 21, 2014

I just want to obtain HikariDataSource with no connections initially as backup datasources, but I found that it still reach maximumPoolSize after a while when I never invoke getConnection() on this dataSource.
Then I found this piece of code:

   @Override
   public void addBagItem()
   {
      class AddConnection implements Runnable
      {
         public void run()
         {
            long sleepBackoff = 200L;
            final int maxPoolSize = configuration.getMaximumPoolSize();
            final int minIdle = configuration.getMinimumIdle();
            while (!isShutdown && totalConnections.get() < maxPoolSize && (minIdle == 0 || getIdleConnections() < minIdle)) {  
               if (!addConnection()) {
                  quietlySleep(sleepBackoff);
                  sleepBackoff = Math.min(1000L, (long) ((double) sleepBackoff * 1.5));
                  continue;
               }

               if (minIdle == 0) {
                  break; // This break is here so we only add one connection when there is no min. idle
               }
            }
         }
      }

      addConnectionExecutor.submit(new AddConnection());
   }

It seems the house keeper thread create one connection each time when minIdle==0, until reach maxPoolSize...

I am wondering why doing things like that? Can we just do nothing when minIdle==0?

@brettwooldridge
Copy link
Owner

It is a bug.

@djj0809
Copy link
Author

djj0809 commented Jul 22, 2014

I will appreciate it if you can fix it soon:)

@brettwooldridge
Copy link
Owner

This is fixed in the dev branch. You will need to build it if you need it before the next release. See the build instructions here.

@djj0809
Copy link
Author

djj0809 commented Jul 22, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants