High Transaction Rollbacks in Langflow ( v1.1.0) in PostgresDB #6647
Replies: 7 comments 5 replies
-
Hey @Sanath1603! I'm here to help you with any bugs, questions, or contributions you have for Langflow. Let's work together to resolve this issue. I found a similar unsolved discussion regarding performance issues with Langflow in production, specifically mentioning a high rollback rate in PostgreSQL. You can check out the discussion here for any updates or potential solutions that might be shared by other users or contributors [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Hi,
Thanks not able to find a solution for this issue. In the given discussion
link if their is any other solution please let me know
…On Sat, 15 Feb, 2025, 3:23 pm dosubot[bot], ***@***.***> wrote:
Hey @Sanath1603 <https://github.com/Sanath1603>! I'm here to help you
with any bugs, questions, or contributions you have for Langflow. Let's
work together to resolve this issue.
I found a similar unsolved discussion regarding performance issues with
Langflow in production, specifically mentioning a high rollback rate in
PostgreSQL. You can check out the discussion here
<#6322> for any
updates or potential solutions that might be shared by other users or
contributors [1]
<#6322>.
*To continue talking to Dosu <https://dosu.dev>, mention @dosu
<https://github.com/dosu>.*
------------------------------
Help Dosu learn! Give it feedback: Great Response
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=great_response>
| Irrelevant Answer
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=irrelevant_answer>
| Incorrect Sources
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=incorrect_sources>
| Too Verbose
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=too_verbose>
| Hallucination
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=hallucination>
| Bug Report
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=bug_report>
| Other
<https://app.dosu.dev/response-feedback/4abcaa2d-5424-48d3-ba4f-d80d4c186de3?feedback_type=other>
—
Reply to this email directly, view it on GitHub
<#6647 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5RSNXT7ODOYTYY34YGAL2P4FC3AVCNFSM6AAAAABXGGCBEGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRQHA2DMOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
The rollbacks are happening for starter project creation and loading . Each
time when the ui is refreshed the labgflow tries to load the starter
project and it's getting failed beacuse of userid and folderid mapped to
the starter project how ro resolve this
…On Sat, 15 Feb, 2025, 3:57 pm dosubot[bot], ***@***.***> wrote:
Langflow triggers a transaction rollback in PostgreSQL when any exception
occurs during database operations, not just IntegrityError. The
transaction management code in Langflow ensures that if any error arises
during a transaction, it is rolled back to maintain database integrity [1]
<https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/database/models/user/crud.py>
[2]
<https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/database/models/transactions/crud.py>
.
If you're experiencing high rollback rates, it might be helpful to
investigate the specific exceptions causing these rollbacks. Unfortunately,
I couldn't find specific configuration settings in Langflow to reduce
rollback frequency or any retry mechanisms for failed transactions. You
might want to check the logs for any error messages that could indicate why
rollbacks are occurring.
*To continue talking to Dosu <https://dosu.dev>, mention @dosu
<https://github.com/dosu>.*
------------------------------
Help Dosu learn! Give it feedback: Great Response
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=great_response>
| Irrelevant Answer
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=irrelevant_answer>
| Incorrect Sources
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=incorrect_sources>
| Too Verbose
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=too_verbose>
| Hallucination
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=hallucination>
| Bug Report
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=bug_report>
| Other
<https://app.dosu.dev/response-feedback/748b8190-281d-4f56-b72a-641dcae6ce21?feedback_type=other>
—
Reply to this email directly, view it on GitHub
<#6647 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5RSIENJBV5OK4BFUGAS32P4JC7AVCNFSM6AAAAABXGGCBEGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRQHA3DCMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Langflow ui tries to access starter project from ui home page that time
rollback happens how to sto this rollback
…On Sat, 15 Feb, 2025, 4:33 pm dosubot[bot], ***@***.***> wrote:
To resolve the issue of transaction rollbacks during starter project
creation and loading in Langflow due to user ID and folder ID mapping
errors, ensure that the user ID and folder ID are correctly set and
validated before committing the transaction. Here are some steps to address
these issues:
1.
*Ensure User ID is Correctly Retrieved:*
Make sure the user ID is correctly retrieved from the database using
the get_user_by_username function. This is crucial when loading flows
from the directory.
user_id = get_user_by_username(session, settings_service.auth_settings.SUPERUSER).id
2.
*Validate Folder ID:*
When creating a new project, ensure that the folder ID is valid and
exists in the database. You can use a function to check if the folder
exists before using its ID.
def folder_exists(session, folder_name):
folder = session.exec(select(Folder).where(Folder.name == folder_name)).first()
return folder is not None
3.
*Create Starter Folder if Not Exists:*
Use a function to create the starter folder if it does not exist. This
ensures that the folder ID used in project creation is valid.
def create_starter_folder(session):
if not folder_exists(session, STARTER_FOLDER_NAME):
new_folder = FolderCreate(name=STARTER_FOLDER_NAME, description=STARTER_FOLDER_DESCRIPTION)
db_folder = Folder.model_validate(new_folder, from_attributes=True)
session.add(db_folder)
session.commit()
session.refresh(db_folder)
return db_folder
else:
return session.exec(select(Folder).where(Folder.name == STARTER_FOLDER_NAME)).first()
4.
*Handle UUID Validation:*
Ensure that any UUIDs used for flow IDs are valid using a validation
function.
def _is_valid_uuid(val):
try:
uuid_obj = UUID(val)
except ValueError:
return False
return str(uuid_obj) == val
By following these steps and ensuring that user IDs and folder IDs are
correctly mapped and validated, you can prevent transaction rollbacks
related to these mapping errors [1]
<https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/initial_setup/setup.py>
.
*To continue talking to Dosu <https://dosu.dev>, mention @dosu
<https://github.com/dosu>.*
------------------------------
Help Dosu learn! Give it feedback: Great Response
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=great_response>
| Irrelevant Answer
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=irrelevant_answer>
| Incorrect Sources
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=incorrect_sources>
| Too Verbose
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=too_verbose>
| Hallucination
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=hallucination>
| Bug Report
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=bug_report>
| Other
<https://app.dosu.dev/response-feedback/22b8a85c-9774-48b5-bf1c-cafed62b6fe9?feedback_type=other>
—
Reply to this email directly, view it on GitHub
<#6647 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5RSO72DTZ3AU7G37KWET2P4NHPAVCNFSM6AAAAABXGGCBEGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRQHA3TMMA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Refer rhe screen shot when am trying to access the flow or folders from
home page rolbacks are happening and all the queries are correct. And how
I can stop rollback for selectquery don't want transaction to be rolled
back how to achieve this
…On Sat, 15 Feb, 2025, 6:31 pm dosubot[bot], ***@***.***> wrote:
To stop the rollbacks when Langflow tries to access the starter project
from the UI home page, ensure that the user ID and folder ID are correctly
retrieved and validated. Here are some steps to help resolve this issue:
1.
*Ensure User ID Retrieval*: Verify that the user ID is correctly
retrieved using the get_user_by_username function. This is crucial for
associating flows with the correct user.
2.
*Validate Folder ID*: Check that the folder ID exists in the database
before using it. Implement a function to verify the existence of the folder.
3.
*Create Starter Folder if Necessary*: Use a function to create the
starter folder if it does not exist. This ensures that the folder ID used
in project creation is valid.
4.
*Check UUID Validity*: Ensure that any UUIDs used for flow IDs are
valid by using a validation function.
By following these steps, you can prevent transaction rollbacks related to
user ID and folder ID mapping errors during the starter project loading
process [1]
<https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/initial_setup/setup.py>
[2]
<https://github.com/logspace-ai/langflow/blob/dev/src/backend/base/langflow/initial_setup/setup.py>
.
*To continue talking to Dosu <https://dosu.dev>, mention @dosu
<https://github.com/dosu>.*
------------------------------
Help Dosu learn! Give it feedback: Great Response
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=great_response>
| Irrelevant Answer
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=irrelevant_answer>
| Incorrect Sources
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=incorrect_sources>
| Too Verbose
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=too_verbose>
| Hallucination
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=hallucination>
| Bug Report
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=bug_report>
| Other
<https://app.dosu.dev/response-feedback/77746b84-de3c-4319-9724-efc2a325cd4a?feedback_type=other>
—
Reply to this email directly, view it on GitHub
<#6647 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5RSL3VVHYLSOBMSTUXET2P43CDAVCNFSM6AAAAABXGGCBEGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRQHEZTKOA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
How implement this for postgres db which is used for storing all the tables
and data in backecode of langflow. Read only mode
…On Mon, 17 Feb, 2025, 9:33 am dosubot[bot], ***@***.***> wrote:
To prevent transaction rollbacks for select queries in Langflow, ensure
that the database operations are executed in a read-only mode. Langflow
uses DuckDB connections with the read_only parameter set to True for
read-only operations, which helps avoid unnecessary transaction rollbacks.
Here's how you can implement this:
1.
*Use Read-Only Connections*: When executing select queries, make sure
the database connection is opened in read-only mode. This can be done by
setting read_only=True in the connection setup.
with duckdb.connect(str(self.db_path), read_only=True) as conn:
df = conn.execute(query).df()
2.
*Check for Exceptions*: Ensure that any exceptions during the
execution of select queries are properly handled. This can prevent
rollbacks triggered by unexpected errors.
3.
*Review Error Handling*: If using SQLAlchemy or similar ORM, review
the error handling logic to ensure that select queries do not trigger
rollbacks. This might involve checking the session management and ensuring
that exceptions are caught and handled appropriately.
By following these steps, you can minimize transaction rollbacks during
select queries in Langflow [1]
<https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/services/monitor/service.py>
.
*To continue talking to Dosu <https://dosu.dev>, mention @dosu
<https://github.com/dosu>.*
------------------------------
Help Dosu learn! Give it feedback: Great Response
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=great_response>
| Irrelevant Answer
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=irrelevant_answer>
| Incorrect Sources
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=incorrect_sources>
| Too Verbose
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=too_verbose>
| Hallucination
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=hallucination>
| Bug Report
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=bug_report>
| Other
<https://app.dosu.dev/response-feedback/ba6f5ec3-3981-44b3-b375-6e935418dc8f?feedback_type=other>
—
Reply to this email directly, view it on GitHub
<#6647 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASP5RSIJ2T5ZNXV5HN7MCU32QFNSZAVCNFSM6AAAAABXGGCBEGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMRRHE3DQNI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I am experiencing a high number of continuous rollbacks in Langflow for both the starter project and my project access. I tested this on version 1.1.0 using PostgreSQL, and I noticed that out of 10 transactions, 7 to 8 are getting rolled back.
How can I resolve this issue? Any help would be greatly appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions