-
Notifications
You must be signed in to change notification settings - Fork 797
Description
Describe the bug
Two related issues seem to be occurring in sequence:
A) If starting query execution (▸ button) while the editor's auto-complete drop-down is still being populated, the query seems to start executing but remains stuck at "Waiting for the query to complete...";
No error or exception is logged.
B) After cancelling the seemingly stuck query (■ button), trying to execute that or any other query in the same Query Tool tab (including an invalid query) pretends to succeed ("Query returned successfully in xx msec." under "Messages") but the "Data Output" is never updated.
The following is logged:
2023-06-02 13:02:39,615: ERROR pgadmin: <asyncio.locks.Lock object at 0x11948dfd0 [unlocked, waiters:1]> is bound to a different event loop
Traceback (most recent call last):
File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/cursor.py", line 281, in execute
return asyncio.run(self._execute(query, params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/cursor.py", line 292, in _execute
return await _async_cursor.execute(self, query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/psycopg/cursor_async.py", line 89, in execute
async with self._conn.lock:
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/locks.py", line 15, in __aenter__
await self.acquire()
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/locks.py", line 106, in acquire
fut = self._get_loop().create_future()
^^^^^^^^^^^^^^^^
File "/Applications/pgAdmin 4.app/Contents/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/mixins.py", line 20, in _get_loop
raise RuntimeError(f'{self!r} is bound to a different event loop')
RuntimeError: <asyncio.locks.Lock object at 0x11948dfd0 [unlocked, waiters:1]> is bound to a different event loop
To Reproduce
Steps to reproduce the behavior:
- Issue A
- Open a new Query Tool tab, or go to an existing Query Tool tab where a previous query was successfully executed;
- Write/paste in a valid query, but do not execute yet;
- Start editing the field names after "SELECT" as to trigger the auto-completion drop-down;
- While the auto-completion suggestions are still loading (drop-down reads "Loading..."), hit the ▸ button to execute the query;
N.B. this step is timing-sensitive and may be best reproduced using a non-local (slow-ish) PG connection; - --> Observe the "Data Output" tab stuck in "Waiting for the query to complete..." mode
- Issue B
- Cancel the query from step 5 above (■ button);
- In the same Query Tool tab, re-execute the query from step 5 (▸ button), or any other query, including an invalid query (which should normally come back with an error from the server);
- --> Observe the "Messages" tab getting the focus, reading "Query returned successfully" (even for a clearly invalid query);
- --> Observe the "Data Output" tab containing whatever it contained prior to step 7 before;
- --> Observe an error being logged to
~/.pgadmin/pgadmin4.log
Workaround: disable "Autocomplete on key press" in the Query Tool options.
Expected behavior
- no stuck query in step 6 above;
- no buggy behavior in steps 10-11 and no error in step 12 above.
Error message
If possible, include the full, unedited text of any error messages displayed.
Screenshots
n/a
Desktop (please complete the following information):
- OS: macOS-12.6.4-x86_64-i386-64bit
- Version: 7.2
- Mode: Desktop
- Browser (if running in server mode): n/a
- Package type: DMG
Additional context
n/a