Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SNOW-160 changes to dev #90

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Fix SNOW-160 changes to dev #90

merged 1 commit into from
Dec 9, 2024

Conversation

philerooski
Copy link
Collaborator

I ran into the following error during the CI pipeline. I believe this is caused by not suspending the root task before trying to resume its dependents on this line: SELECT SYSTEM$TASK_DEPENDENTS_ENABLE('refresh_synapse_warehouse_s3_stage_task');

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.15/x64/bin/schemachange", line 8, in <module>
schemachange version: 3.6.1
Using config file: synapse_data_warehouse/schemachange-config.yml
Using root folder /home/runner/work/snowflake/snowflake/synapse_data_warehouse
Using variables:
  database_name: SYNAPSE_DATA_WAREHOUSE_DEV
  stage_storage_integration: synapse_dev_warehouse_s3
  stage_url: s3://dev.datawarehouse.sagebase.org/warehouse/
  stack: dev

Using Snowflake account ***
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/schemachange/cli.py", line 896, in main
    deploy_command(config)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/schemachange/cli.py", line 577, in deploy_command
    session.apply_change_script(script, content, change_history_table)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/schemachange/cli.py", line 462, in apply_change_script
    self.execute_snowflake_query(script_content)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/schemachange/cli.py", line 367, in execute_snowflake_query
    raise e
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/schemachange/cli.py", line 360, in execute_snowflake_query
    res = self.con.execute_string(query)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/connection.py", line 888, in execute_string
    ret = list(stream_generator)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/connection.py", line 906, in execute_stream
    cur.execute(sql, _is_put_get=is_put_or_get, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/cursor.py", line 1097, in execute
    Error.errorhandler_wrapper(self.connection, self, error_class, errvalue)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/errors.py", line [28](https://github.com/Sage-Bionetworks/snowflake/actions/runs/12242803654/job/34150924180#step:5:29)4, in errorhandler_wrapper
    handed_over = Error.hand_to_other_handler(
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/errors.py", line 339, in hand_to_other_handler
    cursor.errorhandler(connection, cursor, error_class, error_value)
  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/snowflake/connector/errors.py", line 215, in default_errorhandler
    raise error_class(
snowflake.connector.errors.ProgrammingError: 091421 (22000): Unable to update graph with root task SYNAPSE_DATA_WAREHOUSE_DEV.SYNAPSE_RAW.REFRESH_SYNAPSE_WAREHOUSE_S3_STAGE_TASK since that root task is not suspended.
Using default role SYSADMIN
Using default warehouse compute_xsmall
Using default database SYNAPSE_DATA_WAREHOUSE_DEVschema None
Using change history table SYNAPSE_DATA_WAREHOUSE_DEV.SCHEMACHANGE.CHANGE_HISTORY (last altered 2024-11-22 08:24:16.548000-08:00)
Max applied change script version: 2.24.0
Applying change script V2.25.0__add_version_history_to_nodesnapshot.sql
Applying change script V2.25.1__update_node_tasks.sql
Error: Process completed with exit code 1.

@philerooski philerooski requested a review from a team as a code owner December 9, 2024 19:35
Copy link
Member

@thomasyu888 thomasyu888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 LGTM!

@philerooski
Copy link
Collaborator Author

@thomasyu888 I made it a little cleaner by instead modifying this line:

SELECT SYSTEM$TASK_DEPENDENTS_ENABLE('nodesnapshot_task');

Rather than involving the refresh_synapse_warehouse_s3_stage_task at all.

@thomasyu888
Copy link
Member

thomasyu888 commented Dec 9, 2024

@thomasyu888 I made it a little cleaner by instead modifying this line:

SELECT SYSTEM$TASK_DEPENDENTS_ENABLE('nodesnapshot_task');

Rather than involving the refresh_synapse_warehouse_s3_stage_task at all.

@philerooski would that work? because you disabled the refresh task which could disable ALL downstream tasks

@philerooski
Copy link
Collaborator Author

@thomasyu888 I don't suspend the refresh task anymore.

Copy link

sonarqubecloud bot commented Dec 9, 2024

@philerooski
Copy link
Collaborator Author

@thomasyu888 I wasn't able to run the code using a line like

SELECT SYSTEM$TASK_DEPENDENTS_ENABLE('nodesnapshot_task');

Without running into this error: "Task NODESNAPSHOT_TASK should have a SCHEDULE, AFTER, FINALIZE or WHEN to be resumed."

There isn't a way to specify this using SYSTEM$TASK_DEPENDENTS_ENABLE, and I found this in the ALTER TASK docs:

The root task in a task graph must be suspended before any task in the task graph is modified, a child task is suspended or resumed, or a child task is added (using ALTER TASK … AFTER).

So I think it's unavoidable to suspend both upstream and downstream (maybe?) tasks when altering a task.

@philerooski philerooski merged commit 50c47e8 into dev Dec 9, 2024
4 checks passed
@philerooski philerooski deleted the snow-160-fix branch December 9, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants