question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQL Syntax errors on startup

See original GitHub issue

Apache Airflow version: 2.0.0

What happened:

While investigating issues relating to task getting stuck, I saw this sql error in postgres logs. I am not entirely sure of what it impacts but I thought of letting you know.

ERROR:  column "connection.password" must appear in the GROUP BY clause or be used in an aggregate function at character 8
STATEMENT:  SELECT connection.password AS connection_password, connection.extra AS connection_extra, connection.id AS connection_id, connection.conn_id AS connection_conn_id, connection.conn_type AS connection_conn_type, connection.description AS connection_description, connection.host AS connection_host, connection.schema AS connection_schema, connection.login AS connection_login, connection.port AS connection_port, connection.is_encrypted AS connection_is_encrypted, connection.is_extra_encrypted AS connection_is_extra_encrypted, count(connection.conn_id) AS count_1 
        FROM connection GROUP BY connection.conn_id 
        HAVING count(connection.conn_id) > 1
ERROR:  current transaction is aborted, commands ignored until end of transaction block
STATEMENT:  SELECT connection.password AS connection_password, connection.extra AS connection_extra, connection.id AS connection_id, connection.conn_id AS connection_conn_id, connection.conn_type AS connection_conn_type, connection.description AS connection_description, connection.host AS connection_host, connection.schema AS connection_schema, connection.login AS connection_login, connection.port AS connection_port, connection.is_encrypted AS connection_is_encrypted, connection.is_extra_encrypted AS connection_is_extra_encrypted 
        FROM connection 
        WHERE connection.conn_type IS NULL

How to reproduce it:

  1. Run docker-compose run initdb
  2. Run docker-compose run upgradedb
Here's my docker-compose
version: "3.2"
networks:
    airflow:

services:
    postgres:
        container_name: af_postgres
        image: postgres:9.6
        environment:
            - POSTGRES_USER=airflow
            - POSTGRES_DB=airflow
            - POSTGRES_PASSWORD=airflow
        volumes:
            - ./postgresql/data:/var/lib/postgresql/data
        command: >
            postgres
            -c listen_addresses=*
            -c logging_collector=on
            -c log_destination=stderr
        networks:
            - airflow
    initdb:
        container_name: af_initdb
        image: docker.io/apache/airflow:2.0.0-python3.7
        environment:
            - AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
        depends_on:
            - postgres
        entrypoint: /bin/bash
        command: -c "airflow db init"
        networks:
            - airflow
    upgradedb:
        container_name: af_upgradedb
        image: docker.io/apache/airflow:2.0.0-python3.7
        environment:
            - AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
        depends_on:
            - postgres
        entrypoint: /bin/bash
        command: -c "airflow db upgrade"
        networks:
            - airflow

Anything else we need to know:

Upon looking the code, I believe having Connection.conn_id here will resolve the sql syntax error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
kodeinecommented, Sep 17, 2021

Hello @kaxil , I am still getting this error,

ostgresql_1 | 2021-09-17 03:45:45.666 GMT [252] LOG: incomplete startup packet


postgresql_1 | 2021-09-17 03:45:45.735 GMT [254] LOG: incomplete startup packet


airflow-worker_1 | airflow-worker 03:45:45.75 INFO ==> Restoring persisted Airflow installation


airflow-worker_1 | airflow-worker 03:45:45.99 INFO ==> Waiting for Airflow Webserser to be up


postgresql_1 | 2021-09-17 03:45:50.273 GMT [256] ERROR: column connection.description does not exist at character 210

postgresql_1 | 2021-09-17 03:45:50.273 GMT [256] STATEMENT: SELECT connection.password AS connection_password, connection.extra AS connection_extra, connection.id AS connection_id, connection.conn_id AS connection_conn_id, connection.conn_type AS connection_conn_type, connection.description AS connection_description, connection.host AS connection_host, connection.schema AS connection_schema, connection.login AS connection_login, connection.port AS connection_port, connection.is_encrypted AS connection_is_encrypted, connection.is_extra_encrypted AS connection_is_extra_encrypted

postgresql_1 | FROM connection

postgresql_1 | WHERE connection.conn_type IS NULL
1reaction
kaxilcommented, Jan 20, 2021

You are right – https://github.com/apache/airflow/pull/13783 should fix it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging SQL syntax errors - Metabase
Reading an error message shouldn't feel like solving a riddle. This debugging guide explains what you can do about stubborn queries that refuse...
Read more >
Syntax error in SQL statement after upgrading spring-boot ...
I've tested both syntaxes (with and without final comma ",") and both work just fine, as a standalone SQL query, in an SQL...
Read more >
Common SQL syntax errors and how to resolve them
In this article, we are going to describe some of the most common SQL syntax errors, and explains how you can resolve these...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
The Fastest Way To Locate Errors In Your SQL Query
In about 60 seconds you will never debug error messages in SQL Server ... relative to the batch starting point of the erroneous...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found