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

MySQL Server has Gone away #126

Closed
EndenDragon opened this Issue Apr 25, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@EndenDragon

EndenDragon commented Apr 25, 2017

I have been getting these~
OperationalError: (_mysql_exceptions.OperationalError) (2006, 'MySQL server has gone away')

Is there a flag to set when to recycle mysql connections? I know that you can do this with Flask SQLAlchemy with app.config['SQLALCHEMY_POOL_RECYCLE'].

@amol-

This comment has been minimized.

Show comment
Hide comment
@amol-

amol- Apr 25, 2017

Collaborator

How do you create the database cache manager? The namespace manager for database supports a sa_opts parameter where you can pass the pool_recycle option.

Passing session.pool_recylcle config option should also work if you are using session.url as all options ends up being part of sa_opts

Collaborator

amol- commented Apr 25, 2017

How do you create the database cache manager? The namespace manager for database supports a sa_opts parameter where you can pass the pool_recycle option.

Passing session.pool_recylcle config option should also work if you are using session.url as all options ends up being part of sa_opts

@EndenDragon

This comment has been minimized.

Show comment
Hide comment
@EndenDragon

EndenDragon Apr 25, 2017

This is how I created the cache manager
https://github.com/EndenDragon/Titan/blob/master/titanembeds/utils.py#L17

I'm not sure how to initialize and utilize the namespace manager with my webapp.

EndenDragon commented Apr 25, 2017

This is how I created the cache manager
https://github.com/EndenDragon/Titan/blob/master/titanembeds/utils.py#L17

I'm not sure how to initialize and utilize the namespace manager with my webapp.

@amol-

This comment has been minimized.

Show comment
Hide comment
@amol-

amol- Apr 26, 2017

Collaborator

Here is a short snippet to showcase what you are looking for:

from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
cache_opts = {
    'cache.type': 'ext:database',
    'cache.data_dir': 'tmp/cachedata',
    'cache.lock_dir': 'tmp/cachelock',
    'cache.url': 'sqlite:///:memory:',
    'cache.sa.pool_recycle': 250
}
cachemanager = CacheManager(**parse_cache_config_options(cache_opts))
cache = cachemanager.get_cache('test')
engine = cache.namespace.cache.metadata.bind
print engine.pool._recycle

When executed should lead to:

>>> from beaker.cache import CacheManager
>>> from beaker.util import parse_cache_config_options
>>> cache_opts = {
...     'cache.type': 'ext:database',
...     'cache.data_dir': 'tmp/cachedata',
...     'cache.lock_dir': 'tmp/cachelock',
...     'cache.url': 'sqlite:///:memory:',
...     'cache.sa.pool_recycle': 250
... }
>>> cachemanager = CacheManager(**parse_cache_config_options(cache_opts))
>>> cache = cachemanager.get_cache('test')
>>> engine = cache.namespace.cache.metadata.bind
>>> print engine.pool._recycle
250
Collaborator

amol- commented Apr 26, 2017

Here is a short snippet to showcase what you are looking for:

from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
cache_opts = {
    'cache.type': 'ext:database',
    'cache.data_dir': 'tmp/cachedata',
    'cache.lock_dir': 'tmp/cachelock',
    'cache.url': 'sqlite:///:memory:',
    'cache.sa.pool_recycle': 250
}
cachemanager = CacheManager(**parse_cache_config_options(cache_opts))
cache = cachemanager.get_cache('test')
engine = cache.namespace.cache.metadata.bind
print engine.pool._recycle

When executed should lead to:

>>> from beaker.cache import CacheManager
>>> from beaker.util import parse_cache_config_options
>>> cache_opts = {
...     'cache.type': 'ext:database',
...     'cache.data_dir': 'tmp/cachedata',
...     'cache.lock_dir': 'tmp/cachelock',
...     'cache.url': 'sqlite:///:memory:',
...     'cache.sa.pool_recycle': 250
... }
>>> cachemanager = CacheManager(**parse_cache_config_options(cache_opts))
>>> cache = cachemanager.get_cache('test')
>>> engine = cache.namespace.cache.metadata.bind
>>> print engine.pool._recycle
250
@EndenDragon

This comment has been minimized.

Show comment
Hide comment
@EndenDragon

EndenDragon Apr 26, 2017

Awesome!!
cache.sa.pool_recycle config option is exactly what I'm looking for, thanks!!

EndenDragon commented Apr 26, 2017

Awesome!!
cache.sa.pool_recycle config option is exactly what I'm looking for, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment