memgraph / mage

MAGE - Memgraph Advanced Graph Extensions :crystal_ball:
Apache License 2.0
255 stars 26 forks source link

[BUG] Failed do.when() when using database with authentication #214

Closed damianbenente closed 6 months ago

damianbenente commented 1 year ago

Describe the bug Failed do.when() when using database with authentication (work ok when database don't have authentication enabled)

To Reproduce Steps to reproduce the behavior:

  1. Run the following query 'CALL do.when(1>0, "CREATE (:TESTIF {name:timestamp()})","CREATE (:TESTELSE {name:timestamp()})") YIELD test'

Additional context Output Message: `Query failed: do.when: Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/exceptions.py", line 231, in _handler return func(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/connection.py", line 106, in _create_connection connection = mgclient.connect( mgclient.OperationalError: Authentication failure

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/lib/memgraph/query_modules/do.py", line 104, in when return _convert_results(ctx, results) File "/usr/lib/memgraph/query_modules/do.py", line 200, in _convert_results return [ File "/usr/lib/memgraph/query_modules/do.py", line 200, in return [ File "/usr/lib/memgraph/query_modules/do.py", line 185, in _execute_and_fetch_parameterized cursor = memgraph_client._get_cached_connection()._connection.cursor() File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/vendors/database_client.py", line 136, in _get_cached_connection self._cached_connection = self.new_connection() File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/vendors/memgraph.py", line 139, in new_connection return MemgraphConnection(**args) File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/connection.py", line 78, in init self._connection = self._create_connection() File "/usr/local/lib/python3.9/dist-packages/gqlalchemy/exceptions.py", line 235, in _handler raise GQLAlchemyWaitForConnectionError from ex gqlalchemy.exceptions.GQLAlchemyWaitForConnectionError `

Josipmrden commented 1 year ago

We are aware of the issue. It is here (https://github.com/memgraph/mage/blob/main/python/do.py#L98), as GQLAlchemy starts Memgraph with default connection settings (localhost, 7687, no authorization)

katarinasupe commented 1 year ago

Hi @damianbenente, like @Josipmrden stated, this is a bug, and it will be fixed. It would help us to learn more about the urgency on your side to prioritize better. Is this a feature needed for your personal or business project? Is there an alternative way of querying your data until the fix is available?

Btw. what is your use case?

damianbenente commented 1 year ago

no urgency, I was doing conditional writes, looking in the code I fount that it work if define in the environment variables the username and password, maybe adding to the documentation will be nice yes was using the alternative way for query with FOREACH

memgraph-platform: image: "memgraph/memgraph-platform" container_name: memgraph ports:

Josipmrden commented 1 year ago

I think that's actually a very nice approach. We'll take it in for discussion and see if we do any refactoring of the module, or we even go with your approach with possible duplicates.

katarinasupe commented 1 year ago

@Josipmrden I think this is a great quick fix and workaround, but we should still fix the issue in our query modules since the above is not a good developer experience for Memgraph users. Still, it is good to know that there is a workaround.

katarinasupe commented 7 months ago

@Josipmrden can this be closed now?

katarinasupe commented 7 months ago

@damianbenente I think this issue should be fixed with the latest release including MAGE 1.16. Can you verify that so we can close this issue?

damianbenente commented 6 months ago

@katarinasupe Hi, I migrate to another database cause I was having some trouble with the new at that time disk based storage and I was using to much ram. Feel free to close. thanks.

antejavor commented 6 months ago

HI @damianbenente, thanks for the info. This PR: https://github.com/memgraph/mage/pull/461 has a fix for the issue. Let's close it for the time being.