Skip to content

Support URL Config for Pool #811

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

Closed
skeggse opened this issue May 12, 2014 · 15 comments
Closed

Support URL Config for Pool #811

skeggse opened this issue May 12, 2014 · 15 comments
Assignees
Labels
Milestone

Comments

@skeggse
Copy link
Contributor

skeggse commented May 12, 2014

Unless I missed something, the pool's configuration cannot be a url if you want to override the default pool-specific configuration options, including waitForConnections, connectionLimit, and queueLimit.

@dougwilson
Copy link
Member

I'm not really sure if the connection string (which is meant to be for the connection) should be intermingled with the pool (which is application-dependent, really). How about we change it to accept all these:

mysql.createPool({
  // all options; current behavior
})

mysql.createPool(connStr, {
  // pool options
})

mysql.createPool(connOpts, {
  // pool options
})

This would allow the app to control the pool options and let it pass-through whatever the connection options are.

@dougwilson dougwilson self-assigned this May 14, 2014
@dougwilson dougwilson reopened this May 14, 2014
@dougwilson
Copy link
Member

Example here: master...feature;pool-config-conn-string

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

I can see how this syntax could be useful, but we need to be able to configure the pool options in the same place as the connection options. In some applications the pool options can certainly be hardcoded, but in our case that doesn't work.

@dougwilson
Copy link
Member

Can you not just store the configuration as a JSON string and then mysql.createPool(JSON.parse(configurationString))? The connection string format is not really supposed to have anything referencing the pool from it, as the pool is a separate abstraction from actually how to connect to the MySQL database, which is why I'm hesitant.

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

We are basically storing the mysql connection and pool information as a JSON object right now, but it just seems like allowing the following would be useful:

mysql.createPool('mysql://user:pass@localhost:5672/database?connectionLimit=100');

That being said, pools and connections are certainly different abstractions. Tangentially, mongoose allows the url strings to contain information about replicas, which seem like a different abstraction from the mongodb connection itself. I don't know that it's the right connection, but it doesn't seem like the connectionLimit options would ever conflict with connection options.

@dougwilson
Copy link
Member

but it doesn't seem like the connectionLimit options would ever conflict with connection options.

Right, I don't think they would, either.

The other reason why I would rather the pool configuration be separate would be to make it easy to force pool configurations in the app-level, because think if you want to use the same connection string for an entire pool of app servers; some may have different pool configurations that others, but they would all share the same connection string. This is how our enterprise environments function.

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

some may have different pool configurations that others, but they would all share the same connection string.

Which is why I indicated I liked your approach.

It definitely makes sense to allow individual applications to have control over their pooling configuration, but what if you want a central pool config as part of the URL? How about this: let the pool config options exist in the URL, but if specific in a second argument they'll be overridden.

mysql.createPool('...?connectionLimit=100', {
  // overrides the 100 in the URL
  connectionLimit: 50,
  queueLimit: 1000
});

@dougwilson
Copy link
Member

How would you feel about making the pool config in the URL just a single parameter?

mysql://user:pass@localhost:5672/database?poolConfig=%7B%22connectionLimit%22%3A100%7D

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

That could work. It's less readable which is part of the drive for URL-based configurations IMO.

Personally, I like having connectionLimit as its own parameter. What's the drive to have all pool configuration in a single parameter?

@dougwilson
Copy link
Member

What's the drive to have all pool configuration in a single parameter?

Just so there would be a clear separation between pool configuration and connection configuration. We could also do something like:

mysql://user:pass@localhost:5672/database?poolConfig[connectionLimit]=100&poolConfig[waitForConnections]=false

or

mysql://user:pass@localhost:5672/database?poolConnectionLimit=100&poolWaitForConnections=false

We will likely add a debug to the pool config that would be separate from the connection config, among other things. Some current things are already combined together, but I'm trying to keep more new things from also getting combined for these kind of future things.

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

Okay, that makes sense. Those two solutions seem perfectly fine to me, though I prefer the former--poolConfig[connectionLimit]=100 is nice and readable to me.

@dougwilson
Copy link
Member

I may just end up adding your original suggestion. Let me mull it over a bit more ;)

@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

Of course!

@dougwilson
Copy link
Member

Of course!

haha, I'm sorry if I do for dragging you around :) At least I added some actual tests for PoolConfig now (they would have caught the typo in your initial PR).

@dougwilson dougwilson added this to the 2.3 milestone May 14, 2014
@skeggse
Copy link
Contributor Author

skeggse commented May 14, 2014

Tests are always a good thing 😄

dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
…ysqljs#811)

* driver: do not hard fail on flaky checks

* driver: fix cancellation delay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants