Closed gecaro closed 5 months ago
Issue is also seen from various other members of the DBT community using Redshift; since they migrated to use redshift_connector over pyscopg2. Queries that consistently time out locally from me, run fine in SQL workbench type tooling (say 15minute query runs) and never time out.
Hi folks, thanks for the issue report. I took a look at the associated DBT issue and see it has been closed out as a suspected network issue with Codebuild. Regardless, I understand that folks were not seeing this issue with psycopg2 and see it with redshift-connector when using the driver alone with Codebuild. What's weird to me is that issues are seen with psql
and Codebuild. Is the timeout issue consistent for psql
? I see the redshift-connector timeout issue is noted as intermittent but primarily timing out.
Given the repro above is using username/password, redshift-connector is essentially just creating a socket to the host and port provided. As the timeout is occurring on connection, and it only presents on codebuild, I'm inclined to believe this issue is related to the networking settings configured on the CodeBuild machine.
Here's a list of possible things to try that can help us rule out potential issues:
If you don't see resolution, please let me know and the team can investigate further.
Sorry to add confusion with the DBT issue; it was closed before most of the comments were added. Various sources display issues like like Github Actions, Circle CI, but the majority of people commenting in the dbt slack redshift channel about time outs are using local machines to their clusters.
Some generic observations:
Hello all, thanks a lot for your comments.
We have been checking our network settings and we have managed to run successfully the simple redshift-connector
script mentioned above, as well as the psql -h <host> -p 5439 -U <user> -d <db>
statement.
However, we are still encountering issues while running dbt compile
and, in some builds, dbt debug
. Having the debug flag in the compile command returns the following:
16:44:08 Acquiring new redshift connection 'master'
--
646 | 16:44:08 Acquiring new redshift connection 'list_***_***_1711039169_500120b4b6f46f3cc96c3062bee86d05b12a887f'
647 | 16:44:08 Using redshift connection "list_***_***_1711039169_500120b4b6f46f3cc96c3062bee86d05b12a887f"
648 | 16:44:08 On list_***_***_1711039169_500120b4b6f46f3cc96c3062bee86d05b12a887f: BEGIN
649 | 16:44:08 Opening a new connection, currently in state init
650 | 16:44:08 Redshift adapter: Establishing connection using ssl with `sslmode` set to 'require'.To connect without ssl, set `sslmode` to 'disable'.
651 | 16:44:08 Redshift adapter: Connecting to redshift with username/password based auth...
652 | 16:46:18 Redshift adapter: Error running SQL: BEGIN
653 | 16:46:18 Redshift adapter: Rolling back transaction.
654 | 16:46:18 Redshift adapter: Error running SQL: macro list_relations_without_caching
655 | 16:46:18 Redshift adapter: Rolling back transaction.
656 | 16:46:18 On list_***_***_1711039169_500120b4b6f46f3cc96c3062bee86d05b12a887f: No close available on handle
657 | 16:46:18 Connection 'master' was properly closed.
658 | 16:46:18 Connection 'list_***_***_1711039169_500120b4b6f46f3cc96c3062bee86d05b12a887f' was properly closed.
659 | 16:46:18 Encountered an error:
660 | Database Error
661 | ('communication error', TimeoutError(110, 'Connection timed out'))
This failing macro is basically the same sql statement that we are running in our script. At this point, I am assuming dbt has something to do in relation to how the connection is being handled using redshift-connector
. Possibly the best thing now would be to open an issue directly in dbt, but if you know how we may debug further from this point on, I'd be really grateful.
@Brooke-white We're also seeing timeouts when running DBT in GitHub Actions. We initially thought the keep-alive setting is the issue, but it seems to be enabled by default. However, we don't see any setting as to how often a keep-alive package is sent. Do you have any more info on this? Maybe the interval is higher than the session timeout. Just a thought
Driver version
2.0.918
Redshift version
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.63282
Client Operating System
Docker container:
Debian GNU/Linux 11 (bullseye)
onpython3.9
docker image Codebuild: Usingaws/codebuild/standard:7.0
Python version
python3.9
Table schema
Problem description
Expected behaviour: Codebuild machine connecting correctly to redshift.
Actual behaviour: Codebuild machine not connecting to redshift.
Error message/stack trace:
Any other details that can be helpful:
psycopg2
.dbt compile
ordbt run
we had no problems on connecting to redshift with our codebuild environment.redshift-connector
, and we have not been successful as we are getting time outs multiple times.Things we've tried:
redshift-connector
script to do a simple query (to discard that the issue is caused by dbt itself) -> Same result: connection time outpsycopg2
script to do a simple query (to discard that the issue is caused by dbt itself) -> THIS WORKS!psql -h <host> -p 5439 -U <user> -d <db>
-> Same result: connection time outIt is also important to note that we have no problem when running any of the above approaches in our local machines.
Python Driver trace logs
Reproduction code
This does not work, giving the following error:
Whereas the following snippet works: