Closed falonso-alo closed 1 year ago
Just wanted to chime in mentioning that I am seeing this error as well and can confirm that downgrading to 1.4 results in no communication error.
Hello,
I am seeing the same issue but without upgrading to 1.5. It was working perfectly fine on 1.5 until a few hours ago.
Taking a closer look to the packages installed I see that the only difference is a change of the redshift-connector
from redshift-connector-2.0.911
to redshift-connector-2.0.912
.
EDIT: I confirm that downgrading to redshift-connector-2.0.911
after installing dbt-redshift==1.5.5
fixed the issue
@brooke-white, do you have any idea what might have changed in the latest patch that was released today?
EDIT: I confirm that downgrading to
redshift-connector-2.0.911
after installingdbt-redshift==1.5.5
fixed the issue
Hello, I am seeing the same issue but without upgrading to 1.5. It was working perfectly fine on 1.5 until a few hours ago. Taking a closer look to the packages installed I see that the only difference is a change of the
redshift-connector
fromredshift-connector-2.0.911
toredshift-connector-2.0.912
.EDIT: I confirm that downgrading to
redshift-connector-2.0.911
after installingdbt-redshift==1.5.5
fixed the issue
Confirming that downgrading to redshift-connector-2.0.911
worked for my team too
This issue also exists in dbt-redshift 1.5.6. On running dbt debug
, I get the following error.
The exact same issue on 1.5.5
when running dbt compile
, just today. I'll try to follow the advice here and downgrade the package.
Hi, if anyone experiencing this issue could enable redshift-connector's logging and provide the logs it'd be a great help in the redshift-connector team's investigation of this issue. We're working to try and reproduce on our end and will cut a release as soon as a fix is identified. Thanks!
The issue also exists on dbt-core 1.5.2 with dbt-redshift 1.5.6 which appears to install redshift-connector==2.0.912. Confirmed setting redshift-connector to 2.0.911 like others above have mentioned works to resolve this issue.
Does seem to hang a lot long at the initial connection after starting a dbt task but once it starts running it works.
@Brooke-white Here's what we saw in our CI:
Thanks so much, that was extremely helpful :)
I reviewed the trace and was able to reproduce the issue The root cause is this line in DBT. I see the type of port
passed to redshift-connector is dbt.type_helpers.Port rather than int
. A simple fix is to change the line to apply a int case to self.credentials.port
:
"port": int(self.credentials.port) if self.credentials.port else 5439,
for those interested, here is my repro:
from dbt.helper_types import Port
import redshift_connector
with redshift_connector.connect(
user='***',
host='***',
password='***',
database='***',
port = Port(5439),
) as conn:
with conn.cursor() as cursor:
cursor.execute("select 1")
print(cursor.fetchone())
here's my verification of fix:
from dbt.helper_types import Port
import redshift_connector
with redshift_connector.connect(
user='***',
host='***',
password='***',
database='***',
port = int(Port(5439)),
) as conn:
with conn.cursor() as cursor:
cursor.execute("select 1")
print(cursor.fetchone())
happy to open a PR if you folks are ok with this fix.
The root cause is this line in DBT.
if you'll humor me being overly pedantic, this isn't the "root" cause per se. The root cause would be where in the changes issues in 2.0.912
that caused a breaking change in dbt. This code was previously working for months.
silly example:
if I put a 60v battery into a 20v cordless drill and it shorts the drills motor, it would be incorrect to point to the motor as root cause, as the root cause is the battery.
While passing a dbt.helper_types.Port
to the connect method's port parameter worked prior to 2.0.912, it isn't something redshift-connector supports per the docs.
At the end of the day, we don't really need to assign blame anywhere. It's just important that we solve the problem.
Thank you, @Brooke-white!
Agreed with @falonso-alo, I don't think either side (I already don't like that connotation) should be assigning blame. This industry is toxic enough as it is and this work is hard enough as it is. With that in mind, I did some research to understand exactly what is going on and felt like sharing that information.
The initial confusion is coming from that fact that Port
subclasses from int
; in other words, isinstance(Port, int)==True
. We are in fact passing an int
, we're just not passing exactly an int
.
In version v2.0.911
, this line was used to connect via host/port:
https://github.com/aws/amazon-redshift-python-driver/blob/2898d86de9bb6be1e3def88e15c78c9ea767ec52/redshift_connector/core.py#L596
There is no check there to see whether port
is a proper int
. As long as port
can behave like an int
, everyone's happy.
This line was updated in v2.0.912
to:
https://github.com/aws/amazon-redshift-python-driver/blob/b2dde82ec9156e2adcc801ac54c051f3cfe61e33/redshift_connector/core.py#L610-L614
with reference to this new function: https://github.com/aws/amazon-redshift-python-driver/blob/b2dde82ec9156e2adcc801ac54c051f3cfe61e33/redshift_connector/core.py#L397-L409
The new function calls the builtin socket
, which raises the OSError(Int or String expected)
exception that we're seeing. This library must be looking for exactly an int
. I stopped digging at that point as socket
is implemented in C, making it a bit more difficult for me to investigate. While I didn't see the check, I'm willing to assume that there is a check for int
in there.
Putting all of that aside, I have to imagine we're not the only group that is passing a subclass of int
(or str
for that matter) into the Connection
class and expecting it to work (given the argument above). It might not be the primary usage pattern, but until v2.0.912
it appeared to be a valid one. And I'm sure you can appreciate the nuance that comes with sitting on top of code that you can't easily alter (such as socket
in this scenario). So while we aren't passing a proper int
into Connection
, it might be useful for those downstream (both us and other teams) to update this line:
to this:
response = socket.getaddrinfo(host=host, port=int(port), family=socket.AF_INET)
Such is life with dynamic typing in python.
Hi, seems like the error is back. I am on dbt-core=1.5.1
and dbt-redshift=1.5.7
.
06:02:48 Encountered an error while running operation: Database Error
('communication error', OSError('Int or String expected'))
script returned exit code 1
I see in my docker build that redshift-connector-2.0.913
is installed. That version was released 7hrs ago.
@jan-benisek shoot! I've opened #531 to fix this once we're working on a 1.5 patch release to fix this as we speak. I'll reply back here when the patch is out, my estimate is within the next four hours, but certainly in the next 24 hours.
Is it normal to have a stable release that doesn't include dependencies locked in? If that's even an options. 😅 Please excuse my lack of knowledge in app/package development, just generally curious as it'd be great to be able to trust a stable version means it AND the dependancies all work together and new versions of the current package or dependencies won't be integrated together until testing to confirm they're stable. However I can also see how this could be difficult to manage.
dbt-redshift
1.5.8
has now been released. I cannot stress enough how:
dbt-redshift
adapter, and@dataders Thanks a lot for such a quick fix, all 🟢 ! And don't worry, we all have been there. Looking at your fixes, the python driver seems like not the easiest piece of software to work with.
hi @dataders, i'm currently facing this blocker. do i need to downgrade the dbt-redshift adapter?
Is this a regression in a recent version of dbt-redshift?
Current Behavior
dbt compile
fails with a "communication error"/OSError using DBT 1.5.Expected/Previous Behavior
dbt compile
succeeds using DBT 1.4Steps To Reproduce
dbt compile
Relevant log output
No response
Environment
pip packages (working)
``` Package Version ------------------------ -------- agate 1.7.0 annotated-types 0.5.0 appdirs 1.4.4 asn1crypto 1.5.1 attrs 23.1.0 Babel 2.12.1 beautifulsoup4 4.12.2 betterproto 1.2.5 black 23.3.0 boto3 1.26.165 botocore 1.29.165 certifi 2023.5.7 cffi 1.15.1 chardet 5.1.0 charset-normalizer 3.1.0 click 8.1.3 click-config-file 0.6.0 colorama 0.4.6 configobj 5.0.8 dataclasses-json 0.5.4 dbt-core 1.4.6 dbt-extractor 0.4.1 dbt-postgres 1.4.6 dbt-redshift 1.4.0 decorator 5.1.1 diff-cover 7.6.0 exceptiongroup 1.1.2 future 0.18.3 graphql-core 3.2.3 grpclib 0.4.5 gunicorn 20.1.0 h2 4.1.0 hologram 0.0.16 hpack 4.0.0 hyperframe 6.0.1 idna 3.4 iniconfig 2.0.0 isodate 0.6.1 Jinja2 3.1.2 jinja2-simple-tags 0.5.0 jmespath 1.0.1 jsonschema 4.17.3 leather 0.3.4 Logbook 1.5.3 lxml 4.9.3 markdown-it-py 3.0.0 MarkupSafe 2.0.1 marshmallow 3.19.0 marshmallow-enum 1.5.1 mashumaro 3.3.1 mdurl 0.1.2 minimal-snowplow-tracker 0.0.2 montecarlodata 0.40.2 msgpack 1.0.5 multidict 6.0.4 mypy-extensions 1.0.0 networkx 2.8.8 packaging 23.1 parsedatetime 2.4 pathspec 0.10.3 pip 22.0.4 platformdirs 3.8.0 pluggy 1.2.0 protobuf 4.23.3 psycopg2-binary 2.9.6 py 1.11.0 pycarlo 0.7.1 pycparser 2.21 pydantic 2.0.2 pydantic_core 2.1.2 Pygments 2.15.1 pyrsistent 0.19.3 pytest 7.4.0 python-box 7.0.1 python-dateutil 2.8.2 python-slugify 8.0.1 pytimeparse 1.1.8 pytz 2023.3 PyYAML 6.0 redshift-connector 2.0.912 regex 2023.6.3 requests 2.31.0 retry 0.9.2 rich 13.4.2 ruamel.yaml 0.17.32 ruamel.yaml.clib 0.2.7 s3transfer 0.6.1 scramp 1.4.4 setuptools 58.1.0 sgqlc 14.1 shandy-sqlfmt 0.19.0 six 1.16.0 soupsieve 2.4.1 sqlfluff 2.1.2 sqlfluff-templater-dbt 2.1.2 sqlparse 0.4.3 stringcase 1.2.0 tabulate 0.9.0 tblib 2.0.0 text-unidecode 1.3 toml 0.10.2 tomli 2.0.1 tqdm 4.65.0 typing_extensions 4.7.1 typing-inspect 0.9.0 urllib3 1.26.16 Werkzeug 2.1.2 ```pip packages (regression)
``` Package Version ------------------------ -------- agate 1.7.0 annotated-types 0.5.0 appdirs 1.4.4 asn1crypto 1.5.1 attrs 23.1.0 Babel 2.12.1 beautifulsoup4 4.12.2 betterproto 1.2.5 black 23.3.0 boto3 1.26.165 botocore 1.29.165 certifi 2023.5.7 cffi 1.15.1 chardet 5.1.0 charset-normalizer 3.1.0 click 8.1.3 click-config-file 0.6.0 colorama 0.4.6 configobj 5.0.8 dataclasses-json 0.5.4 dbt-core 1.5.2 dbt-extractor 0.4.1 dbt-postgres 1.5.2 dbt-redshift 1.5.0 decorator 5.1.1 diff-cover 7.6.0 exceptiongroup 1.1.2 future 0.18.3 graphql-core 3.2.3 grpclib 0.4.5 gunicorn 20.1.0 h2 4.1.0 hologram 0.0.16 hpack 4.0.0 hyperframe 6.0.1 idna 3.4 iniconfig 2.0.0 isodate 0.6.1 Jinja2 3.1.2 jinja2-simple-tags 0.5.0 jmespath 1.0.1 jsonschema 4.17.3 leather 0.3.4 Logbook 1.5.3 lxml 4.9.3 markdown-it-py 3.0.0 MarkupSafe 2.0.1 marshmallow 3.19.0 marshmallow-enum 1.5.1 mashumaro 3.6 mdurl 0.1.2 minimal-snowplow-tracker 0.0.2 montecarlodata 0.40.2 msgpack 1.0.5 multidict 6.0.4 mypy-extensions 1.0.0 networkx 2.8.8 packaging 23.1 parsedatetime 2.4 pathspec 0.10.3 pip 22.0.4 platformdirs 3.8.0 pluggy 1.2.0 protobuf 4.23.3 psycopg2-binary 2.9.6 py 1.11.0 pycarlo 0.7.1 pycparser 2.21 pydantic 2.0.2 pydantic_core 2.1.2 Pygments 2.15.1 pyrsistent 0.19.3 pytest 7.4.0 python-box 7.0.1 python-dateutil 2.8.2 python-slugify 8.0.1 pytimeparse 1.1.8 pytz 2023.3 PyYAML 6.0 redshift-connector 2.0.912 regex 2023.6.3 requests 2.31.0 retry 0.9.2 rich 13.4.2 ruamel.yaml 0.17.32 ruamel.yaml.clib 0.2.7 s3transfer 0.6.1 scramp 1.4.4 setuptools 58.1.0 sgqlc 14.1 shandy-sqlfmt 0.19.0 six 1.16.0 soupsieve 2.4.1 sqlfluff 2.1.2 sqlfluff-templater-dbt 2.1.2 sqlparse 0.4.3 stringcase 1.2.0 tabulate 0.9.0 tblib 2.0.0 text-unidecode 1.3 toml 0.10.2 tomli 2.0.1 tqdm 4.65.0 typing_extensions 4.7.1 typing-inspect 0.9.0 urllib3 1.26.16 Werkzeug 2.1.2 ```Additional Context
Tested in a venv.