Comments (1)
To mitigate issues with dead sessions in MySQL due to network settings, you can configure the SQLAlchemy connection pool with specific parameters. Here are some options you can use:
- Pool Recycle: Ensures that connections are recycled after a specified number of seconds to avoid idle connections being closed by MySQL.
- Pool Pre-Ping: Enables a "ping" operation to test connections before they are used, replacing invalid connections with new ones.
- Pool Timeout: Specifies the number of seconds to wait before giving up on getting a connection from the pool.
Here is how you can configure these options in your create_engine
call within the DatabaseService
class:
from sqlalchemy import create_engine
def _create_engine(self) -> "Engine":
"""Create the engine for the database."""
settings_service = get_settings_service()
if settings_service.settings.DATABASE_URL and settings_service.settings.DATABASE_URL.startswith("sqlite"):
connect_args = {"check_same_thread": False}
else:
connect_args = {}
return create_engine(
self.database_url,
connect_args=connect_args,
pool_recycle=3600, # Recycle connections after 1 hour
pool_pre_ping=True, # Enable pre-ping to test connections
pool_timeout=30, # Wait up to 30 seconds for a connection
max_overflow=-1
)
In this example:
pool_recycle=3600
ensures that connections are recycled every hour.pool_pre_ping=True
enables the pre-ping feature to test connections before they are used.pool_timeout=30
sets the timeout for getting a connection from the pool to 30 seconds.
These settings should help mitigate issues with dead sessions in MySQL due to network settings.
You can find the relevant code in the service.py
file of the langflow
repository. Here is the link to the file for reference: src/backend/langflow/services/database/service.py.
Details
Sources
- src/backend/langflow/services/database/service.py
- src/backend/base/langflow/services/database/service.py
- src/backend/base/langflow/services/settings/manager.py
- src/backend/base/langflow/services/settings/service.py
- src/backend/base/langflow/services/settings/service.py
- src/backend/base/langflow/components/experimental/SQLExecutor.py
- src/backend/base/langflow/services/monitor/utils.py
- src/backend/base/langflow/services/monitor/utils.py
- src/backend/base/langflow/services/monitor/service.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from langflow.
Related Issues (20)
- I can't connect api to the new langflow pre release this is the body HOT 3
- Error in API cURL option, JSON malformed and missing closing } on tweaks object HOT 2
- Lock type inconsistency between set_cache and upsert methods HOT 5
- flow disappears from hugging face HOT 6
- poetry going in an infinite loop in installing spacy HOT 2
- pre-release version Installation with pip failed and spacy install loop HOT 6
- RAG and Tool usage , at the same time HOT 2
- Pinecone Search Component not returning records HOT 2
- Langflow run | Migration Issue HOT 3
- Langflow UI stuck in Building without actually building the components HOT 2
- Installation Issue in MacOS HOT 3
- [Security Issue] Code Execution against underlying host system in Custom Component HOT 7
- I can't auth to web ui (deploy with docker frontend+backend) HOT 5
- Request for ARM64 Support in LangFlow Docker Images HOT 1
- Upgrade 35a to 37a fails with couchbase building wheel HOT 2
- __enter__ Error after start node (docker deploy) HOT 13
- The error - duplicate 'folder_id' in alembic HOT 1
- Unable to upload file to folder HOT 5
- Langflow split text error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.