Skip to content

[BUG] Mgclient "failed to send chunk data" error when running execute_and_fetch() in Python Flask Application #59

Open
@dipasupil

Description

@dipasupil

Memgraph version Which version did you use?

2.6

Environment Some information about the environment you are using Memgraph
on: operating system, how do you connect, with or without docker, which driver
etc.

Operating System: Amazon Linux 2.
Use Docker w/ default settings.

Describe the bug A clear and concise description of what the bug is.

I have a Python Flask web application. One of the pages has a form that when submitted, calls Memgraph.exceute_and_fetch() to query the Memgraph database using data in the form. The returned data will then be used to populate a Memgraph Orb graph and render it to the user on new page.

Sometimes, instead of receiving node/edge data from the query, a Database Error will be returned, typically on users' first session or first session in a while. Specifically, this is an mgclient error that say "failed to send chunk data". Upon page refresh/form resubmission, the query is successful and the results render as normal and the error is not encountered again (until a future session, typically hours or day(s) later).

To Reproduce Steps to reproduce the behavior:

  1. Have Memgraph instance running and connect to that Memgraph instance using GQLAlchemy in a Python Flask Application.
  2. Have a page in the Flask Application with a form in it, and upon form submission, will run a query using GQL Alchemy's Memgraph.execute_and_fetch() method.
  3. If successful, the query will run as normal and return intended results/redirect users to the right page. However, on occasion (for a reason I can't quite narrow down), the mgclient error will be thrown. (Picture below)
  4. If the error is thrown, refreshing page and resubmitting form should always result in query being successful.

Expected behavior A clear and concise description of what you expected to
happen.

I expect the query to be successful on the first try, rather than upon a form resubmission (or repeating the excecute_and_fetch() call on the backend to ensure users don't see the error. This has "solved" the problem currently from a user standpoint, but we still see the error printed in the terminal logs. )

Logs If applicable, add logs of Memgraph, CLI output or screenshots to help
explain your problem.

image
image

Additional context Add any other context about the problem here.

DB and Query are initialized/run like this:

from gqlalchemy import Node, Field, Relationship, Memgraph, Path
db = Memgraph(host='host-link.net', port=7687)
query_result = db.execute_and_fetch(query=query, connection=db)
results = list(query_result)
  • Currently, the Flask app is being run in the same server as the Memgraph database.
  • Error text/throw seems to be found here:
    mg_session_set_error(session, "failed to send chunk data");

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions