snowflake-connector-python
snowflake-connector-python copied to clipboard
SNOW-275768: - Task exited with return code Negsignal.SIGABRT. Airflow task fails with snowflakeOperator
Please answer these questions before submitting your issue. Thanks!
- What version of Python are you using (
python --version)? 3.7.3 - What operating system and processor architecture are you using (
python -c 'import platform; print(platform.platform())')? Darwin-19.5.0-x86_64-i386-64bit - What are the component versions in the environment (
pip freeze)?
alembic==1.5.3
apache-airflow==2.0.0
apache-airflow-providers-ftp==1.0.0
apache-airflow-providers-http==1.0.0
apache-airflow-providers-imap==1.0.0
apache-airflow-providers-snowflake==1.0.0
apache-airflow-providers-sqlite==1.0.0
apispec==3.3.2
argcomplete==1.12.2
asn1crypto==1.4.0
attrs==20.3.0
auditwheel==3.1.1
azure-common==1.1.25
azure-core==1.8.2
azure-storage-blob==12.5.0
azure-storage-common==2.1.0
Babel==2.9.0
boto3==1.15.18
botocore==1.18.18
cached-property==1.5.2
cattrs==1.2.0
certifi==2020.4.5.1
cffi==1.14.3
chardet==3.0.4
click==7.1.2
clickclick==20.10.2
colorama==0.4.4
colorlog==4.0.2
commonmark==0.9.1
configparser==3.5.3
connexion==2.7.0
croniter==0.3.37
cryptography==2.9.2
defusedxml==0.6.0
dill==0.3.3
dnspython==2.1.0
docutils==0.16
email-validator==1.1.2
Flask==1.1.2
Flask-Admin==1.5.4
Flask-AppBuilder==3.1.1
Flask-Babel==1.0.0
Flask-Caching==1.9.0
Flask-JWT-Extended==3.25.0
Flask-Login==0.4.1
Flask-OpenID==1.2.5
Flask-SQLAlchemy==2.4.4
flask-swagger==0.2.13
Flask-WTF==0.14.3
funcsigs==1.0.2
future==0.18.2
graphviz==0.16
gunicorn==19.10.0
idna==2.10
importlib-metadata==1.7.0
importlib-resources==1.5.0
inflection==0.5.1
iso8601==0.1.13
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.3
jmespath==0.10.0
json-merge-patch==0.2
jsonschema==3.2.0
lazy-object-proxy==1.4.3
lockfile==0.12.2
Mako==1.1.4
Markdown==2.6.11
MarkupSafe==1.1.1
marshmallow==3.10.0
marshmallow-enum==1.5.1
marshmallow-oneofschema==2.1.0
marshmallow-sqlalchemy==0.23.1
msrest==0.6.19
natsort==7.1.1
numpy==1.20.0
oauthlib==3.1.0
openapi-spec-validator==0.2.9
oscrypto==1.2.1
packaging==20.9
pandas==1.2.1
pendulum==2.1.2
prison==0.1.3
psutil==5.8.0
pyarrow==3.0.0
pycparser==2.20
pycryptodomex==3.9.8
pyelftools==0.26
Pygments==2.7.4
PyJWT==1.7.1
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyrsistent==0.17.3
python-daemon==2.2.4
python-dateutil==2.8.1
python-editor==1.0.4
python-nvd3==0.15.0
python-slugify==4.0.1
python3-openid==3.2.0
pytz==2020.1
pytzdata==2020.1
PyYAML==5.4.1
requests==2.23.0
requests-oauthlib==1.3.0
rich==9.2.0
s3transfer==0.3.3
setproctitle==1.2.2
six==1.15.0
snowflake-connector-python==2.3.7
snowflake-sqlalchemy==1.2.4
SQLAlchemy==1.3.23
SQLAlchemy-JSONField==1.0.0
SQLAlchemy-Utils==0.36.8
swagger-ui-bundle==0.0.8
tabulate==0.8.7
tenacity==6.2.0
termcolor==1.1.0
text-unidecode==1.3
thrift==0.13.0
typing-extensions==3.7.4.3
tzlocal==1.5.1
unicodecsv==0.14.1
urllib3==1.25.11
Werkzeug==1.0.1
WTForms==2.3.3
zipp==3.4.0
zope.deprecation==4.4.0
- What did you do?
from airflow import DAG
from airflow.providers.snowflake.operators.snowflake import SnowflakeOperator
from airflow.utils.dates import days_ago
SNOWFLAKE_CONN_ID = 'snowflake_conn'
# TODO: should be able to rely on connection's schema, but currently param required by S3ToSnowflakeTransfer
# SNOWFLAKE_SCHEMA = 'schema_name'
#SNOWFLAKE_STAGE = 'stage_name'
SNOWFLAKE_WAREHOUSE = 'SF_TUTS_WH'
SNOWFLAKE_DATABASE = 'KAFKA_DB'
SNOWFLAKE_ROLE = 'sysadmin'
SNOWFLAKE_SAMPLE_TABLE = 'sample_table'
CREATE_TABLE_SQL_STRING = (
f"CREATE OR REPLACE TRANSIENT TABLE {SNOWFLAKE_SAMPLE_TABLE} (name VARCHAR(250), id INT);"
)
SQL_INSERT_STATEMENT = f"INSERT INTO {SNOWFLAKE_SAMPLE_TABLE} VALUES ('name', %(id)s)"
SQL_LIST = [SQL_INSERT_STATEMENT % {"id": n} for n in range(0, 10)]
default_args = {
'owner': 'airflow',
}
dag = DAG(
'example_snowflake',
default_args=default_args,
start_date=days_ago(2),
tags=['example'],
)
snowflake_op_sql_str = SnowflakeOperator(
task_id='snowflake_op_sql_str',
dag=dag,
snowflake_conn_id=SNOWFLAKE_CONN_ID,
sql=CREATE_TABLE_SQL_STRING,
warehouse=SNOWFLAKE_WAREHOUSE,
database=SNOWFLAKE_DATABASE,
# schema=SNOWFLAKE_SCHEMA,
role=SNOWFLAKE_ROLE,
)
snowflake_op_with_params = SnowflakeOperator(
task_id='snowflake_op_with_params',
dag=dag,
snowflake_conn_id=SNOWFLAKE_CONN_ID,
sql=SQL_INSERT_STATEMENT,
parameters={"id": 56},
warehouse=SNOWFLAKE_WAREHOUSE,
database=SNOWFLAKE_DATABASE,
# schema=SNOWFLAKE_SCHEMA,
role=SNOWFLAKE_ROLE,
)
snowflake_op_sql_list = SnowflakeOperator(
task_id='snowflake_op_sql_list', dag=dag, snowflake_conn_id=SNOWFLAKE_CONN_ID, sql=SQL_LIST
)
snowflake_op_sql_str >> [
snowflake_op_with_params,
snowflake_op_sql_list,]
-
What did you expect to see? snowflake_op_sql_str task should run fine.
-
What did you see instead?
*** Reading local file: /Users/aashayjain/airflow/logs/snowflake_test/snowflake_op_with_params/2021-02-02T13:51:18.229233+00:00/1.log
[2021-02-02 19:21:38,880] {taskinstance.py:826} INFO - Dependencies all met for <TaskInstance: snowflake_test.snowflake_op_with_params 2021-02-02T13:51:18.229233+00:00 [queued]>
[2021-02-02 19:21:38,887] {taskinstance.py:826} INFO - Dependencies all met for <TaskInstance: snowflake_test.snowflake_op_with_params 2021-02-02T13:51:18.229233+00:00 [queued]>
[2021-02-02 19:21:38,887] {taskinstance.py:1017} INFO -
--------------------------------------------------------------------------------
[2021-02-02 19:21:38,887] {taskinstance.py:1018} INFO - Starting attempt 1 of 1
[2021-02-02 19:21:38,887] {taskinstance.py:1019} INFO -
--------------------------------------------------------------------------------
[2021-02-02 19:21:38,892] {taskinstance.py:1038} INFO - Executing <Task(SnowflakeOperator): snowflake_op_with_params> on 2021-02-02T13:51:18.229233+00:00
[2021-02-02 19:21:38,895] {standard_task_runner.py:51} INFO - Started process 16510 to run task
[2021-02-02 19:21:38,901] {standard_task_runner.py:75} INFO - Running: ['airflow', 'tasks', 'run', 'snowflake_test', 'snowflake_op_with_params', '2021-02-02T13:51:18.229233+00:00', '--job-id', '7', '--pool', 'default_pool', '--raw', '--subdir', 'DAGS_FOLDER/snowflake_test.py', '--cfg-path', '/var/folders/6h/1pzt4pbx6h32h6p5v503wws00000gp/T/tmp1w61m38s']
[2021-02-02 19:21:38,903] {standard_task_runner.py:76} INFO - Job 7: Subtask snowflake_op_with_params
[2021-02-02 19:21:38,933] {logging_mixin.py:103} INFO - Running <TaskInstance: snowflake_test.snowflake_op_with_params 2021-02-02T13:51:18.229233+00:00 [running]> on host 1.0.0.127.in-addr.arpa
[2021-02-02 19:21:38,954] {taskinstance.py:1232} INFO - Exporting the following env vars:
AIRFLOW_CTX_DAG_OWNER=airflow
AIRFLOW_CTX_DAG_ID=snowflake_test
AIRFLOW_CTX_TASK_ID=snowflake_op_with_params
AIRFLOW_CTX_EXECUTION_DATE=2021-02-02T13:51:18.229233+00:00
AIRFLOW_CTX_DAG_RUN_ID=manual__2021-02-02T13:51:18.229233+00:00
[2021-02-02 19:21:38,955] {snowflake.py:119} INFO - Executing: INSERT INTO TEST_TABLE VALUES ('name', %(id)s)
[2021-02-02 19:21:38,961] {base.py:74} INFO - Using connection to: id: snowflake_conn. Host: uva00063.us-east-1.snowflakecomputing.com, Port: None, Schema: , Login: abcde, Password: XXXXXXXX, extra: XXXXXXXX
[2021-02-02 19:21:38,963] {connection.py:218} INFO - Snowflake Connector for Python Version: 2.3.7, Python Version: 3.7.3, Platform: Darwin-19.5.0-x86_64-i386-64bit
[2021-02-02 19:21:38,964] {connection.py:769} INFO - This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.
[2021-02-02 19:21:38,964] {connection.py:785} INFO - Setting use_openssl_only mode to False
[2021-02-02 19:21:38,996] {local_task_job.py:118} INFO - Task exited with return code Negsignal.SIGABRT
- Can you set logging to DEBUG and collect the logs?
import logging
import os
for logger_name in ['snowflake.sqlalchemy', 'snowflake.connector', 'botocore']:
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
logger.addHandler(ch)
Hardcoded the sql to -- Executing: INSERT INTO TEST_TABLE VALUES ('name', 123) still same error. https://stackoverflow.com/questions/66012040/task-exited-with-return-code-negsignal-sigabrt-airflow-task-fails-with-snowflak/66014071?noredirect=1#comment116731955_66014071
Hey @aashayVimeo are you able to log into the UI and observe that the queries show up in your history?
I'd say that reaching out to our support might be the fastest way to resolve your issue https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge
hi @sfc-gh-mkeller , I am able to login to the UI , but cant see the queries show up in history.
Then I'd guess that you are hitting some issue with logging in.
I was hitting the same error and was able to get pass it by adding export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in the .zshrc file as explained here: https://github.com/apache/airflow/issues/12808
I think the issue are facing has to do with OCSP checking
Add "insecure_mode=True" in snowflake connector to disable OCSP checking
snowflake.connector.connect(
insecure_mode=True,
)
But "insecure_mode=True" is needed only when running inside Airflow (Running as a pyscript works fine) . I don't know why is that.
To clean up and re-prioritize bugs and feature requests we are closing all issues older than 6 months as of March 1, 2023. If there are any issues or feature requests that you would like us to address, please re-create them. For urgent issues, opening a support case with this link Snowflake Community is the fastest way to get a response