You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "kunjmehta (via GitHub)" <gi...@apache.org> on 2024/06/10 16:49:12 UTC

[I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

kunjmehta opened a new issue, #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912

   ### What would you like help with?
   
   Hi, 
   
   I am running a Python 3.12 script following the recipes to try and use FlightSQL Postgresql adapter (v0.1.0) with the Python FlightSQL driver. This is on a Ubuntu WSL 1 VM on Windows 10 with Postgres 15 and FlightSQL adapter extension added as required from [here](https://arrow.apache.org/flight-sql-postgresql/0.1.0/configuration.html)
   
   Script:
   ```
   import adbc_driver_flightsql.dbapi
   
   uri = "grpc://localhost:15432/"
   username = 'postgres'
   password = 'postgres'
   
   conn = adbc_driver_flightsql.dbapi.connect(uri, 
                                           db_kwargs={'username': username, 'password': password,
                                      'adbc.flight.sql.rpc.call_header.x-flight-sql-database': 'postgres'
                                      })
   
   cur = conn.cursor()
   cur.execute("SELECT 1;")   # stuck on this line
   print(cur.fetchall())
   ```
   
   This is what I see when I debug the code with a breakpoint on the call to `execute`:
   ![image](https://github.com/apache/arrow-adbc/assets/32904245/c0e74e7f-b085-4a8a-8ab6-03b5712a8ae1)
   
   The detail stacktrace for `adbc_current_catalog`:
   
   >  Traceback (most recent call last):\n  File "/home/kunjmehta10/.vscode-server/extensions/ms-python.python-2021.5.926500501/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py", line 193, in _get_py_dictionary\n    attr = getattr(var, name)\n           ^^^^^^^^^^^^^^^^^^\n  File "/home/kunjmehta10/miniconda3/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 531, in adbc_current_catalog\n    return self._conn.get_option(key)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "adbc_driver_manager/_lib.pyx", line 812, in adbc_driver_manager._lib.AdbcConnection.get_option\n  File "adbc_driver_manager/_lib.pyx", line 237, in adbc_driver_manager._lib.check_error\nadbc_driver_manager.ProgrammingError: NOT_FOUND: [Flight SQL] failed to get current catalog: Not Found: [Flight SQL] current catalog not supported\n'
   
   I am not sure if I am doing anything wrong or if I missed something but any help is appreciated!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "kunjmehta (via GitHub)" <gi...@apache.org>.
kunjmehta commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2160857061

   Hi, no worries! I did enable the env variable and it does debug like in cases where connection not available. However, in the case of query execution getting stuck, it doesn't log anything until I force quit when it shows the screenshot below because token expired at timeout
   
   ![image](https://github.com/apache/arrow-adbc/assets/32904245/0c374754-9acf-48f5-a096-d43440e9ec7f)
   
   Think it is just stuck without any error. Any idea?
   
   Also checked if RPC URL is accessible via telnet, and it is.
   
   ![image](https://github.com/apache/arrow-adbc/assets/32904245/1a64e4b9-77e1-4a89-9f12-a2d71761dcde)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "jduo (via GitHub)" <gi...@apache.org>.
jduo commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2166637518

   The latest is actually just the head of the main branch 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2160023181

   Hey - sorry, it may be a few days before I can get to this
   
   In the meantime the env var ADBC_DRIVER_FLIGHTSQL_LOG_LEVEL=debug might show which call precedes the one it hangs on 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "kunjmehta (via GitHub)" <gi...@apache.org>.
kunjmehta commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2166614318

   @jduo I did build from source following instructions from [here](https://arrow.apache.org/flight-sql-postgresql/0.1.0/install.html#source). It says to use version 0.1.0
   
   If you can tell me what the latest is, I can rebuild


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "jduo (via GitHub)" <gi...@apache.org>.
jduo commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2166241474

   Hi @kunjmehta ,
   
   It looks like 0.1.0 is a fairly old version of the PostgreSQL Flight SQL Adapter. There were improvements made, including those around prepared statements afterwards but you'll need to build from source.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "kunjmehta (via GitHub)" <gi...@apache.org>.
kunjmehta commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2166078559

   I was able to get it unstuck following this parameter setting idea from [here](https://github.com/apache/arrow-flight-sql-postgresql/issues/178) and this is the stack trace I got
   
   > Traceback (most recent call last):
     File "/mnt/d/Projects/Timescale/sqlflight.py", line 53, in <module>
       cur.execute("SELECT $1;", parameters=(42,))
     File "/home/kunjmehta10/miniconda3/envs/arrow/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 698, in execute
       handle, self._rowcount = _blocking_call(
                                ^^^^^^^^^^^^^^^
     File "adbc_driver_manager/_lib.pyx", line 1552, in adbc_driver_manager._lib._blocking_call_impl
     File "adbc_driver_manager/_lib.pyx", line 1545, in adbc_driver_manager._lib._blocking_call_impl
     File "adbc_driver_manager/_lib.pyx", line 1195, in adbc_driver_manager._lib.AdbcStatement.execute_query
     File "adbc_driver_manager/_lib.pyx", line 237, in adbc_driver_manager._lib.check_error
   adbc_driver_manager.OperationalError: IO: [FlightSQL] error reading from server: EOF (Unavailable; ExecuteQuery)
   During handling of the above exception, another exception occurred:
   Traceback (most recent call last):
     File "/mnt/d/Projects/Timescale/sqlflight.py", line 52, in <module>
       with conn.cursor() as cur:
     File "/home/kunjmehta10/miniconda3/envs/arrow/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 235, in __exit__
       self.close()
     File "/home/kunjmehta10/miniconda3/envs/arrow/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 637, in close
       self._stmt.close()
     File "adbc_driver_manager/_lib.pyx", line 1167, in adbc_driver_manager._lib.AdbcStatement.close
     File "adbc_driver_manager/_lib.pyx", line 1173, in adbc_driver_manager._lib.AdbcStatement.close
     File "adbc_driver_manager/_lib.pyx", line 237, in adbc_driver_manager._lib.check_error
   adbc_driver_manager.OperationalError: IO: [FlightSQL] connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:15432: connect: connection refused" (Unavailable; ClosePreparedStatement)
   Exception ignored in: <function Cursor.__del__ at 0x7f95a7df82c0>
   Traceback (most recent call last):
     File "/home/kunjmehta10/miniconda3/envs/arrow/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 795, in __del__
     File "/home/kunjmehta10/miniconda3/envs/arrow/lib/python3.12/site-packages/adbc_driver_manager/dbapi.py", line 637, in close
     File "adbc_driver_manager/_lib.pyx", line 1166, in adbc_driver_manager._lib.AdbcStatement.close
     File "adbc_driver_manager/_lib.pyx", line 303, in adbc_driver_manager._lib._AdbcHandle._close_child
     File "adbc_driver_manager/_lib.pyx", line 305, in adbc_driver_manager._lib._AdbcHandle._close_child
   RuntimeError: Underflow in closing this AdbcStatement


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python FlightSQL Driver stuck on query execution [arrow-adbc]

Posted by "jduo (via GitHub)" <gi...@apache.org>.
jduo commented on issue #1912:
URL: https://github.com/apache/arrow-adbc/issues/1912#issuecomment-2166373456

   Oh, I thought the problem was still around ClosePreparedStatement but then saw this:
   
   `cur.execute("SELECT $1;", parameters=(42,))`
   
   The Flight SQL adapter for PostgreSQL doesn't support bound parameters. It supports only prepared statements without parameters.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org