dbt-core: [CT-3506] [Bug] dbt-core using psycopg2-binary==2.9.6 succeeds, but psycopg2-binary==2.9.9 does not.
Is this a regression in a recent version of dbt-core?
- I believe this is a regression in dbt-core functionality
- I have searched the existing issues, and I could not find an existing issue for this regression
Current Behavior
I have installed dbt-core and dbt-postgres from scratch on a fresh MacOS machine (macOS 14.2 (23C64), Darwin 23.2.0) in a virtual python environment running Python 3.10.13.
When using the command pip3 install dbt-postgres, followed by a dbt debug to confirm connectivity, aconnection error is encountered with the message attached in the log section below.
To work around this, you can run pip3 uninstall psycopg2-binary && pip3 install psycopg2-binary==2.9.6. Without changing network settings or profile information, the connection suceeds!
Expected/Previous Behavior
The connection using username & password based authentication should succeed without having to install the proper version of the psycopg2-binary package.
Steps To Reproduce
- Create a new Python environment on MacOS (ARM64) using Python version 3.10 (also tested on 3.11, same result).
- Activate newly-created python environment.
- Run standard install command:
pip3 install dbt-postgres. - Navigate terminal to known-good dbt project.
- Execute command
dbt debugto confirm connectivity to database in~/.dbt/profile.yml. - Observe connection failure due to improper authentication strategy being attempted.
- Uninstall
psycopg2-binaryusingpip3:pip3 uninstall psycopg2-binary. - Install downgraded version of
psycopg2-binary==2.9.6. - Re-execute command
dbt debugand observe proper authentication strategy being utilized.
Relevant log output
~/Documents/Development/DBT/network_data_warehouse on KNIME-12 ❯ dbt debug dbt-new 3.10.13 at 02:38:13 PM
19:38:19 Running with dbt=1.7.4
19:38:19 dbt version: 1.7.4
19:38:19 python version: 3.10.13
19:38:19 python path: /Users/mwendel/.pyenv/versions/3.10.13/envs/dbt-new/bin/python3.10
19:38:19 os info: macOS-14.2-arm64-arm-64bit
19:38:19 Using profiles dir at /Users/mwendel/.dbt
19:38:19 Using profiles.yml file at /Users/mwendel/.dbt/profiles.yml
19:38:19 Using dbt_project.yml file at /Users/mwendel/Documents/Development/DBT/network_data_warehouse/dbt_project.yml
19:38:19 adapter type: postgres
19:38:19 adapter version: 1.7.4
19:38:19 Configuration:
19:38:19 profiles.yml file [OK found and valid]
19:38:19 dbt_project.yml file [OK found and valid]
19:38:19 Required dependencies:
19:38:19 - git [OK found]
19:38:19 Connection:
[.......]
19:38:19 Registered adapter: postgres=1.7.4
19:38:40 Connection test: [ERROR]
19:38:40 1 check failed:
19:38:40 dbt was unable to connect to the specified database.
The database returned the following error:
>Database Error
connection to server at "<redacted>" (<redacted>), port <redacted> failed: could not initiate GSSAPI security context: Unspecified GSS failure. Minor code may provide more information: Server not found in Kerberos database
connection to server at "<redacted>" (<redacted>), port <redacted> failed: timeout expired
Environment
- OS: macOS 14.2 (23C64), Darwin 23.2.0
- Python: 3.11.* or 3.10.*
- dbt (working version): unknown (package dependency issue)
- dbt (regression version): unknown (package dependency issue)
Which database adapter are you using with dbt?
postgres
Additional Context
I’m not sure when this was introduced, but a possibly relevant line can be found in this file: dbt-core/plugins/postgres/setup.py.
Not sure if it means anything - sorry i’m not too familiar with Python projects or this codebase 😃
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 15 (6 by maintainers)
Still faced this issue today, this was the only fix for me. Tried connecting my Postgres DB from Docker to dbt but it did not work until I used this version of psycopg2
For me, the ticket seems to be created when I connect via Microsoft Remote Desktop connection to a windows machine on my Mac.
This creates a ticket in the ticket view for that authentication which will eventually expire. When I have an expired ticket psycopg will hang for a few minutes when trying to authenticate a connection like it’s trying to connect to some Kerberos Server somewhere and it cannot to try and authenticate. This occurs when connecting to a local postgres instance (either in docker or on the native machine)
I’m no expert on Kerberos and maybe this is completely the wrong direction, but I’d be curious if the original reporter has the same issue with an expired kerberos identity and if removing it helps?
The ticket viewer can be found via search or from the menu option on the Keychain Access
@jamesrusso Great ideas 💡
Do you know how to handle expired tickets through the “Ticket Viewer” application?
Is there a way to renew it? Or does it need to be deleted?
If you can provide any screenshots or other instructions for @ooobii, that would be awesome!
Will the connection eventually succeed (after like 3 minutes?) Do you have any expired tickets in your OSX “Ticket Viewer” application. I suspect its some issue with GSSAPI interactions on OSX and the underlying postgres module.
I just experienced it again because of an expired ticket in the ticket view from me connecting from OSX to a windows file share.