pgadmin-org / pgadmin4

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://www.pgadmin.org
Other
2.45k stars 642 forks source link

PgAdmin error 'NoneType' object has no attribute '_query' #7660

Closed kmarimuthu90 closed 2 months ago

kmarimuthu90 commented 3 months ago

PgAdmin Setup Details:

kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
    meta.helm.sh/release-name: pgadmin
    meta.helm.sh/release-namespace: pgadmin4
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  creationTimestamp: "2024-07-03T12:28:00Z"
  generation: 3
  labels:
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: pgadmin4
    app.kubernetes.io/version: "8.8"
    helm.sh/chart: pgadmin4-1.26.0
  name: pgadmin-pgadmin4
  namespace: pgadmin4
  resourceVersion: "699311774"
  uid: 5801c0f3-42c7-4663-922f-e3b83dfc7e2b
spec:
  rules:
  - host: pgadmin-nonprod.com
    http:
      paths:
      - backend:
          service:
            name: pgadmin-pgadmin4
            port:
              number: 8080
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - pgadmin-nonprod.com
    secretName: tls-secret-pgadmin

pgadmin service running on AKS:

PS D:\2024-Q3\pgadmin-upgrade\pgadmin4> kubectl get svc -npgadmin4
NAME               TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)          AGE
pgadmin-pgadmin4   LoadBalancer   10.X.X.X   13.X.X.X  8080:31735/TCP   2d

Issue:

When we run the below query it returns 'NoneType' object has no attribute '_query'

select * from tenant where a.tenant_id not in 
(select tenant_id from tenant_app_tier_mapping where application_id=6 and status='A') a 
order by tenant_id desc;

Logs from the PgAdmin pod:

2024-07-01 13:50:51,056: ERROR  pgadmin:        'NoneType' object has no attribute '_query'
Traceback (most recent call last):
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 304, in inner
    return mfa_enabled(
           ^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 169, in mfa_enabled
    return execute_if_enabled()
           ^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 301, in if_else_func_inner
    return _func(first, second)
           ^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 242, in mfa_session_authenticated
    return authenticated() if session.get('mfa_authenticated', False) is True \
           ^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 297, in execute_func
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/user_login_check.py", line 22, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/tools/sqleditor/__init__.py", line 992, in poll
    conn._Connection__async_cursor._query)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_query'

Here are the values.yaml for the pgadmin deployment:

VolumePermissions:
  enabled: false
affinity: {}
annotations: {}
autoscaling:
  enabled: true
  maxReplicas: 2
  minReplicas: 1
  targetCPUUtilizationPercentage: 70
  targetMemoryUtilizationPercentage: 70
commonLabels: {}
containerPorts:
  http: 8080
containerSecurityContext:
  allowPrivilegeEscalation: false
  enabled: false
env:
  email: *************
  enhanced_cookie_protection: "False"
  password: **********
  variables:
  - name: PGADMIN_LISTEN_PORT
    value: "8080"
  - name: PGADMIN_CONFIG_WTF_CSRF_CHECK_DEFAULT
    value: "False"
  - name: PGADMIN_CONFIG_WTF_CSRF_ENABLED
    value: "False"
  - name: PGADMIN_CONFIG_CONSOLE_LOG_LEVEL
    value: "10"
envVarsExtra: []
envVarsFromConfigMaps: []
envVarsFromSecrets: []
existingSecret: ""
extraConfigmapMounts: []
extraContainers: ""
extraDeploy: []
extraInitContainers: ""
extraSecretMounts: []
extraVolumeMounts: []
extraVolumes: []
image:
  pullPolicy: IfNotPresent
  registry: docker.io
  repository: dpage/pgadmin4
  tag: ""
ingress:
  annotations:
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  enabled: true
  hosts:
  - host: pgadmin-nonprod.com
    paths:
    - path: /
      pathType: Prefix
  tls:
  - hosts:
    - pgadmin-nonprod.com
    secretName: tls-secret-pgadmin
init:
  resources: {}
livenessProbe:
  failureThreshold: 3
  initialDelaySeconds: 30
  periodSeconds: 60
  successThreshold: 1
  timeoutSeconds: 15
namespace: null
networkPolicy:
  enabled: true
nodeSelector:
  agentpool: appnodepool
persistentVolume:
  accessModes:
  - ReadWriteOnce
  annotations: {}
  enabled: true
  size: 6Gi
podAnnotations: {}
podLabels: {}
priorityClassName: ""
readinessProbe:
  failureThreshold: 3
  initialDelaySeconds: 30
  periodSeconds: 60
  successThreshold: 1
  timeoutSeconds: 15
replicaCount: 1
resources:
  limits:
    cpu: 500m
    memory: 1Gi
  requests:
    cpu: 250m
    memory: 512Mi
secretKeys:
  pgadminPasswordKey: password
securityContext:
  fsGroup: 5050
  runAsGroup: 5050
  runAsUser: 5050
serverDefinitions:
  enabled: false
  existingConfigmap: ""
  existingSecret: ""
  resourceType: ConfigMap
  servers: null
service:
  annotations: {}
  clusterIP: ""
  loadBalancerIP: ""
  port: 8080
  portName: http
  targetPort: 8080
  type: LoadBalancer
serviceAccount:
  annotations: {}
  automountServiceAccountToken: false
  create: false
  name: ""
strategy: {}
templatedPodAnnotations: ""
test:
  image:
    registry: docker.io
    repository: busybox
    tag: latest
  resources: {}
  securityContext:
    fsGroup: 5051
    runAsGroup: 5051
    runAsUser: 5051
tolerations:
- effect: NoSchedule
  key: pool
  operator: Equal
  value: app00

Kindly help on this pls

kmarimuthu90 commented 3 months ago

image

khushboovashi commented 3 months ago

Hi @kmarimuthu90, I couldn't reproduce this issue. Did you face this issue with all the queries or a particular one? Have you tried using any other Postgres server?

kmarimuthu90 commented 3 months ago

It's happening randomly in Postgresql queries. We are facing this issue on all env from dev to prod PostgreSQL flexible server db

kmarimuthu90 commented 3 months ago

I am using this helm chart, helm repo add runix https://helm.runix.net helm pull runix/pgadmin4 --untar --version 1.26.0

khushboovashi commented 3 months ago

@kmarimuthu90, whenever you encounter this error, please check the connection status through Dashboard. This error will occur only if the query tool loses its connection cursor; in that case, pgAdmin should show the connection lost popup.

kmarimuthu90 commented 3 months ago

I don't see any connection loss here

image

image

Sometimes we get results like this,

Select query from the same query tool, image

kmarimuthu90 commented 3 months ago

Is there any doc available to install pgadmin with nginx ingress by using helm?

Ctrl-Elite commented 2 months ago

Is there any update? I'm having the same issue (Not using K8S, just in Docker).

2024-07-19 08:35:38,078: ERROR pgadmin: 'NoneType' object has no attribute '_query' Traceback (most recent call last): File "/venv/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view return current_app.ensure_sync(func)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 304, in inner return mfa_enabled( ^^^^^^^^^^^^ File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 169, in mfa_enabled return execute_if_enabled() ^^^^^^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 301, in if_else_func_inner return _func(first, second) ^^^^^^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 242, in mfa_session_authenticated return authenticated() if session.get('mfa_authenticated', False) is True \ ^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/authenticate/mfa/utils.py", line 297, in execute_func return wrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/user_login_check.py", line 22, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/pgadmin4/pgadmin/tools/sqleditor/__init__.py", line 992, in poll conn._Connection__async_cursor._query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute '_query'

khushboovashi commented 2 months ago

@Ctrl-Elite,

We have fixed the issue; you can test it on the snapshot. docker pull dpage/pgadmin4:snapshot

RohitBhati8269 commented 2 months ago

Issue fixed and verified with snapshot-build OS - macOS/Ubuntu

kmarimuthu90 commented 2 months ago

Hi team,

Is this fix included in any of the helm chart app version? I am using helm chart pgadmin4-1.26.0 and app version 8.8.

Thanks, Krishnakumar.M

On Mon, Jul 22, 2024 at 1:39 AM Rohit Bhati @.***> wrote:

Closed #7660 https://github.com/pgadmin-org/pgadmin4/issues/7660 as completed.

— Reply to this email directly, view it on GitHub https://github.com/pgadmin-org/pgadmin4/issues/7660#event-13597663376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQEA5P6RHOBHFXKA7MI6MP3ZNTAKLAVCNFSM6AAAAABKJRKAJWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGU4TONRWGMZTONQ . You are receiving this because you were mentioned.Message ID: @.***>

khushboovashi commented 2 months ago

@kmarimuthu90, we do not support the helm chart. We have fixed this issue and will be available in the next release. You need to keep an eye on the helm chart updated version which will include this fix.