Thread: Upgradede Pgadmin4 to v6.12 - new startup error

Upgradede Pgadmin4 to v6.12 - new startup error

From
Cherio
Date:
This was just a regular upgrade (I went through dozens of these).
The new 6.12 version fails to start with the following error message:

  File "lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 93, in <module>
    app = create_app()
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 270, in create_app
    create_app_data_directory(config)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 117, in create_app_data_directory
    _create_directory_if_not_exists(config.AZURE_CREDENTIAL_CACHE_DIR)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
    os.mkdir(_path)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pgadmin/azurecredentialcache'

My setup has absolutely nothing to do with Azure. I use python wheel having PgAdmin installed in an unprivileged environment, so I am puzzled why it is all of sudden trying to look for something in "/var/lib/pgadmin" or create things there?

Re: Upgradede Pgadmin4 to v6.12 - new startup error

From
Cherio
Date:
I grepped the sources for 'azurecredentialcache':

user@HOST:~/opt/pgadmin4$ grep -R azurecredentialcache .
./lib/python3.8/site-packages/pgadmin4/config.py:AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

I do re-define DATA_DIR in my configuration file (see below) so it is unclear why it is trying to create something in "/var/lib/pgadmin":

user@HOST:~/opt/pgadmin4$ cat ./lib/python3.8/site-packages/pgadmin4/config_local.py
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.config/pgadmin-v4/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
PGADMIN_INT_PORT=xxxx
DEFAULT_SERVER_PORT=xxxx
SERVER_MODE = False
MASTER_PASSWORD_REQUIRED = False

I skipped version 6.11 and upgraded from 6.10 so I can't say whether this broke in 6.11 or 6.12.

On Mon, Aug 1, 2022 at 10:09 AM Cherio <cherio@gmail.com> wrote:
This was just a regular upgrade (I went through dozens of these).
The new 6.12 version fails to start with the following error message:

  File "lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 93, in <module>
    app = create_app()
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 270, in create_app
    create_app_data_directory(config)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 117, in create_app_data_directory
    _create_directory_if_not_exists(config.AZURE_CREDENTIAL_CACHE_DIR)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
    os.mkdir(_path)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pgadmin/azurecredentialcache'

My setup has absolutely nothing to do with Azure. I use python wheel having PgAdmin installed in an unprivileged environment, so I am puzzled why it is all of sudden trying to look for something in "/var/lib/pgadmin" or create things there?

Re: Upgradede Pgadmin4 to v6.12 - new startup error

From
Dave Page
Date:
Hi

On Mon, 1 Aug 2022 at 16:01, Cherio <cherio@gmail.com> wrote:
I grepped the sources for 'azurecredentialcache':

user@HOST:~/opt/pgadmin4$ grep -R azurecredentialcache .
./lib/python3.8/site-packages/pgadmin4/config.py:AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

I do re-define DATA_DIR in my configuration file (see below) so it is unclear why it is trying to create something in "/var/lib/pgadmin":

Almost certainly because config_local.py is read at the end of config.py, so the change you make to DATA_DIR isn't reflected by AZURE_CREDENTIAL_CACHE_DIR.
 

user@HOST:~/opt/pgadmin4$ cat ./lib/python3.8/site-packages/pgadmin4/config_local.py
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.config/pgadmin-v4/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
PGADMIN_INT_PORT=xxxx
DEFAULT_SERVER_PORT=xxxx
SERVER_MODE = False
MASTER_PASSWORD_REQUIRED = False

Try adding the following to config_local.py:

AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

That will ensure it gets reset after you redefine DATA_DIR.

I think we have some docs/comments about re-defining things if you change DATA_DIR; I'll go check they mention AZURE_CREDENTIAL_CACHE_DIR as well.
 

I skipped version 6.11 and upgraded from 6.10 so I can't say whether this broke in 6.11 or 6.12.

On Mon, Aug 1, 2022 at 10:09 AM Cherio <cherio@gmail.com> wrote:
This was just a regular upgrade (I went through dozens of these).
The new 6.12 version fails to start with the following error message:

  File "lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 93, in <module>
    app = create_app()
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 270, in create_app
    create_app_data_directory(config)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 117, in create_app_data_directory
    _create_directory_if_not_exists(config.AZURE_CREDENTIAL_CACHE_DIR)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
    os.mkdir(_path)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pgadmin/azurecredentialcache'

My setup has absolutely nothing to do with Azure. I use python wheel having PgAdmin installed in an unprivileged environment, so I am puzzled why it is all of sudden trying to look for something in "/var/lib/pgadmin" or create things there?



--

Re: Upgradede Pgadmin4 to v6.12 - new startup error

From
Cherio
Date:
Thanks Dave! The application started after I added the line you suggested 👍🏻. Although in my opinion, trying to work around a new feature in order to start pgadmin feels wrong.

I have 2 follow-up questions.

1. Presently I have to redefine paths for several files and directories (see below). Is there a better way/place to define DATA_DIR so that subdirectories and files in it need not be explicitly redefined? It just doesn't feel like a good design pattern :)

LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

2. I am guessing the new "azurecredentialcache" directory is related to the new feature that adds "support for Azure PostgreSQL deployment in server mode". Why is it trying to create new directories in an environment that has nothing to do with Azure?


On Mon, Aug 1, 2022 at 11:10 AM Dave Page <dpage@pgadmin.org> wrote:
Hi

On Mon, 1 Aug 2022 at 16:01, Cherio <cherio@gmail.com> wrote:
I grepped the sources for 'azurecredentialcache':

user@HOST:~/opt/pgadmin4$ grep -R azurecredentialcache .
./lib/python3.8/site-packages/pgadmin4/config.py:AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

I do re-define DATA_DIR in my configuration file (see below) so it is unclear why it is trying to create something in "/var/lib/pgadmin":

Almost certainly because config_local.py is read at the end of config.py, so the change you make to DATA_DIR isn't reflected by AZURE_CREDENTIAL_CACHE_DIR.
 

user@HOST:~/opt/pgadmin4$ cat ./lib/python3.8/site-packages/pgadmin4/config_local.py
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.config/pgadmin-v4/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
PGADMIN_INT_PORT=xxxx
DEFAULT_SERVER_PORT=xxxx
SERVER_MODE = False
MASTER_PASSWORD_REQUIRED = False

Try adding the following to config_local.py:

AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

That will ensure it gets reset after you redefine DATA_DIR.

I think we have some docs/comments about re-defining things if you change DATA_DIR; I'll go check they mention AZURE_CREDENTIAL_CACHE_DIR as well.
 

I skipped version 6.11 and upgraded from 6.10 so I can't say whether this broke in 6.11 or 6.12.

On Mon, Aug 1, 2022 at 10:09 AM Cherio <cherio@gmail.com> wrote:
This was just a regular upgrade (I went through dozens of these).
The new 6.12 version fails to start with the following error message:

  File "lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 93, in <module>
    app = create_app()
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 270, in create_app
    create_app_data_directory(config)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 117, in create_app_data_directory
    _create_directory_if_not_exists(config.AZURE_CREDENTIAL_CACHE_DIR)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
    os.mkdir(_path)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pgadmin/azurecredentialcache'

My setup has absolutely nothing to do with Azure. I use python wheel having PgAdmin installed in an unprivileged environment, so I am puzzled why it is all of sudden trying to look for something in "/var/lib/pgadmin" or create things there?



--

Re: Upgradede Pgadmin4 to v6.12 - new startup error

From
Dave Page
Date:
Hi

On Mon, 1 Aug 2022 at 16:46, Cherio <cherio@gmail.com> wrote:
Thanks Dave! The application started after I added the line you suggested 👍🏻. Although in my opinion, trying to work around a new feature in order to start pgadmin feels wrong.


I agree. The difficulty is though that we either fail early, or fail later which would likely affect fewer users, but would be much harder to detect reliably as it’s an external process that would fail(in this case, azure-cli I believe).

I have 2 follow-up questions.

1. Presently I have to redefine paths for several files and directories (see below). Is there a better way/place to define DATA_DIR so that subdirectories and files in it need not be explicitly redefined? It just doesn't feel like a good design pattern :)

LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

Yeah, it’s a chicken and egg problem, and it has mildly annoyed me in the past too. I’ll give it some more thought.


2. I am guessing the new "azurecredentialcache" directory is related to the new feature that adds "support for Azure PostgreSQL deployment in server mode". Why is it trying to create new directories in an environment that has nothing to do with Azure?

It has no way to know that you’re not going to use that feature - for all we or it knows, your boss might ask you to evaluate PostgreSQL on Azure next week :-)



On Mon, Aug 1, 2022 at 11:10 AM Dave Page <dpage@pgadmin.org> wrote:
Hi

On Mon, 1 Aug 2022 at 16:01, Cherio <cherio@gmail.com> wrote:
I grepped the sources for 'azurecredentialcache':

user@HOST:~/opt/pgadmin4$ grep -R azurecredentialcache .
./lib/python3.8/site-packages/pgadmin4/config.py:AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

I do re-define DATA_DIR in my configuration file (see below) so it is unclear why it is trying to create something in "/var/lib/pgadmin":

Almost certainly because config_local.py is read at the end of config.py, so the change you make to DATA_DIR isn't reflected by AZURE_CREDENTIAL_CACHE_DIR.
 

user@HOST:~/opt/pgadmin4$ cat ./lib/python3.8/site-packages/pgadmin4/config_local.py
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.config/pgadmin-v4/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
PGADMIN_INT_PORT=xxxx
DEFAULT_SERVER_PORT=xxxx
SERVER_MODE = False
MASTER_PASSWORD_REQUIRED = False

Try adding the following to config_local.py:

AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

That will ensure it gets reset after you redefine DATA_DIR.

I think we have some docs/comments about re-defining things if you change DATA_DIR; I'll go check they mention AZURE_CREDENTIAL_CACHE_DIR as well.
 

I skipped version 6.11 and upgraded from 6.10 so I can't say whether this broke in 6.11 or 6.12.

On Mon, Aug 1, 2022 at 10:09 AM Cherio <cherio@gmail.com> wrote:
This was just a regular upgrade (I went through dozens of these).
The new 6.12 version fails to start with the following error message:

  File "lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 93, in <module>
    app = create_app()
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 270, in create_app
    create_app_data_directory(config)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 117, in create_app_data_directory
    _create_directory_if_not_exists(config.AZURE_CREDENTIAL_CACHE_DIR)
  File "/path-to/opt/pgadmin4/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
    os.mkdir(_path)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pgadmin/azurecredentialcache'

My setup has absolutely nothing to do with Azure. I use python wheel having PgAdmin installed in an unprivileged environment, so I am puzzled why it is all of sudden trying to look for something in "/var/lib/pgadmin" or create things there?



--
--
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.

Re: Content assist / autocomplete hangs the server (latest pgAdmin version)

From
Akshay Joshi
Date:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     

Re: Content assist / autocomplete hangs the server (latest pgAdmin version)

From
Calle Hedberg
Date:
Hi,

I would like to echo Cherio's suggestion here. I copy/paste and run very complex scripts every day, and after the recent changes I see the same: "Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual."

When things get really slow I find that I have to close pgadmin completely and re-open it, and if I had let us say 20 tabs open I have to re-create them - painful.

Note that I really LIKE autocomplete to be on when writing NEW scripts, it can be a timesaver. But I cannot turn it off and turn it on again 30 times a day - the scripts I'm running are a mix of existing-run-as-is, existing-modify-run, and new-run. Autocomplete pops up after the semicolon I always put at the end of any script when it's finished, so if you could enable a switch to turn autocomplete off if a semicolon is present it would be helpful...  (I generally do NOT want auto-complete when just editing old scripts).

One specific issue I've noticed is that whenever I paste a complex script, I have to wait for the "Loading...." to disappear before executing, or else I get that "ERROR: execute cannot be used while an asynchronous query is underway" message. That's new, but I presume it is doing some kind of script checking and it usually is quick, so that's OK. 

NOTE, though, that the hourglass icon to the left of the URL does not change to "this session is idle.." etc, it still says "a command is currently in progress" until you have actually executed something

Screenshot latest pgAdmin.png

Best regards
Calle Hedberg

On Fri, 5 Aug 2022 at 10:35, Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     



--

Carl-Anders (Calle) Hedberg

HISP

Researcher & Technical Specialist

Health Information Systems Programme – South Africa

Cell:        +47 41461011 (Norway)

Iridium SatPhone: +8816-315-19119 (usually OFF)

E-mail1: calle@hisp.org

E-mail2: calle.hedberg@gmail.com

Skype:  calle_hedberg

Attachment

Re: Content assist / autocomplete hangs the server (latest pgAdmin version)

From
Akshay Joshi
Date:
Hi Calle

On Fri, Aug 5, 2022 at 3:03 PM Calle Hedberg <calle.hedberg@gmail.com> wrote:
Hi,

I would like to echo Cherio's suggestion here. I copy/paste and run very complex scripts every day, and after the recent changes I see the same: "Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual."

When things get really slow I find that I have to close pgadmin completely and re-open it, and if I had let us say 20 tabs open I have to re-create them - painful.

Note that I really LIKE autocomplete to be on when writing NEW scripts, it can be a timesaver. But I cannot turn it off and turn it on again 30 times a day - the scripts I'm running are a mix of existing-run-as-is, existing-modify-run, and new-run. Autocomplete pops up after the semicolon I always put at the end of any script when it's finished, so if you could enable a switch to turn autocomplete off if a semicolon is present it would be helpful...  (I generally do NOT want auto-complete when just editing old scripts).

One specific issue I've noticed is that whenever I paste a complex script, I have to wait for the "Loading...." to disappear before executing, or else I get that "ERROR: execute cannot be used while an asynchronous query is underway" message. That's new, but I presume it is doing some kind of script checking and it usually is quick, so that's OK. 

    We have fixed an issue to stop autocomplete on arrow keys/meta keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build. Can you please test and let us know whether it is better/worse than the existing one? You can press the ESC key to delete the 'Loading...' option.

NOTE, though, that the hourglass icon to the left of the URL does not change to "this session is idle.." etc, it still says "a command is currently in progress" until you have actually executed something

Screenshot latest pgAdmin.png

Best regards
Calle Hedberg

On Fri, 5 Aug 2022 at 10:35, Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     



--

Carl-Anders (Calle) Hedberg

HISP

Researcher & Technical Specialist

Health Information Systems Programme – South Africa

Cell:        +47 41461011 (Norway)

Iridium SatPhone: +8816-315-19119 (usually OFF)

E-mail1: calle@hisp.org

E-mail2: calle.hedberg@gmail.com

Skype:  calle_hedberg



--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     

Attachment
Thanks Akshay, that's what I meant by "switched autocomplete to manual".

That however doesn't really address the issue. I can still bring down the pgAdmin backend (for everyone using it) by clicking Ctrl+Space on a complex/rogue SQL.

On Fri, Aug 5, 2022 at 4:35 AM Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     

Re: Content assist / autocomplete hangs the server (latest pgAdmin version)

From
Aditya Toshniwal
Date:
Akshay,

We need to think on cancelling the autocomplete in the backend after a certain timeout.

On Fri, Aug 5, 2022 at 7:08 PM Cherio <cherio@gmail.com> wrote:
Thanks Akshay, that's what I meant by "switched autocomplete to manual".

That however doesn't really address the issue. I can still bring down the pgAdmin backend (for everyone using it) by clicking Ctrl+Space on a complex/rogue SQL.

On Fri, Aug 5, 2022 at 4:35 AM Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     



--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | edbpostgres.com
"Don't Complain about Heat, Plant a TREE"

Re: Content assist / autocomplete hangs the server (latest pgAdmin version)

From
Akshay Joshi
Date:


On Mon, Aug 8, 2022 at 9:25 AM Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Akshay,

We need to think on cancelling the autocomplete in the backend after a certain timeout.

    Sure, will check. 

On Fri, Aug 5, 2022 at 7:08 PM Cherio <cherio@gmail.com> wrote:
Thanks Akshay, that's what I meant by "switched autocomplete to manual".

That however doesn't really address the issue. I can still bring down the pgAdmin backend (for everyone using it) by clicking Ctrl+Space on a complex/rogue SQL.

On Fri, Aug 5, 2022 at 4:35 AM Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Cherio

You can disable the automatic autocomplete option from "File -> Preferences -> Query Tool -> Auto completion -> Autocomplete on key press". We have also fixed an issue to stop autocomplete on arrow keys #7573 which will be available in the next release, meanwhile, you can install the snapshot build.



On Wed, Aug 3, 2022 at 11:39 PM Cherio <cherio@gmail.com> wrote:
I had to examine certain aspects of a query that looks like this:

SELECT COUNT(*)
FROM schema.table
WHERE id IN (
'1',
'2',
'3',
....
'19998',
'19999',
'20000'
)

I pasted the query and autocomplete kicked in. For a minute it froze entirely. Then it sort of let me do things but everything was like in slow motion: the tree browser, the other SQL tabs - everything became slow as molasses. I logged onto the server and the "pgAdmin4.py" was keeping the CPU quite busy. It didn't recover for some time so I simply restarted the server and switched autocomplete to manual.

Not knowing the design I may not be able to make a viable suggestion but maybe some sort of complexity counter (configurable or at least hard-coded at first) should be considered, which would hint to the autocomplete to stop trying, after it realizes the task may be too complex or takes too long to complete.

Sure, a query like the one above should probably make use of a temporary table but it is beyond the point - there has to be a safeguard against an overloaded autocomplete. Without such a safeguard an ugly/invalid query or a user error could kill the server for all connected pgadmin clients.


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com

     



--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | edbpostgres.com
"Don't Complain about Heat, Plant a TREE"


--

Akshay Joshi

Principal Software Architect

+91 9767888246

www.enterprisedb.com