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

Changed the default value for max_open_connections to one. #8

Closed
wants to merge 3 commits into from

Conversation

christ0pher
Copy link

If the value is Leq 0 an error over the python logging system ist emitted. This can be used to catch failures over network logging and custom defined handlers.

Connections are now checked only against the max_open property.

…ue is Leq 0 a warning over the python logging system ist emitted.

Connections are now checked only against the max_open property.
@methane
Copy link
Member

methane commented May 12, 2015

Why should I change the default?
Why not use exception instead of logging?

@christ0pher
Copy link
Author

Hi,

  1. The default value should be a reasonable value. 0 for unlimited open connections looks more like a hack to me, instead of a reasonable value. Unlimited connections do not make sense in the context of databases (e.g file descriptor limit). If you use a pool a reasonable value is 1 to open at max one connection.
  2. exceptions in constructors are not a nice way to show the error. Better way is to set the default value to a reasonable value. Also an unlimited amout of connections will crash the db if the load gets too high.

best

@methane
Copy link
Member

methane commented May 13, 2015

The default value should be a reasonable value. 0 for unlimited open connections looks more like a hack to me, instead of a reasonable value. Unlimited connections do not make sense in the context of databases (e.g file descriptor limit). If you use a pool a reasonable value is 1 to open at max one connection.

I don't feel 1 is reasonable value. It's too small for real application.

http://golang.org/pkg/database/sql/#DB.SetMaxOpenConns
Go's connection pool is unlimited by default.

exceptions in constructors are not a nice way to show the error.

I disagree. Exception is better than logging.
Python's Zen saids:

Errors should never pass silently.

I really like it. If people misconfigured, libraries should crash ASAP.

@christ0pher
Copy link
Author

Ok. i will change it to an exception.

But still initializing databasepools with unlimited connections is not the way to go. Even in GO.

…ant for two reasons: First if you have a software system and you chose to use database pools you should be aware of how many connections may be opened to the database servers. Especially when using micro-services where more than one service accesses the database. Second initializing values with unlimited is useless, because there is no such thing as infinite connections to servers or the like.

If the values are not initialized properly a ValueException is raised to indicate that the initialization is wrong.
@christ0pher
Copy link
Author

Additional thoughts to the commit message:
If you have a product and many services can open unlimited connection pools to the database, it is possible to bring down your hole product with just one service.
People who program should be aware what they are doing, but sometimes a little hint might be useful to build more reliable systems.

@@ -14,6 +14,7 @@

DEBUG = False

POOLLOGGER = logging.getLogger("Tornado-MySQL")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

@methane
Copy link
Member

methane commented May 16, 2015

Our company use this module in production already.
Please don't break backward compatibility so easy.

…nnection pools. This change is not backwards compatible. The reason for this is, that the default initialization is not useful.
@methane methane closed this Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants