https://prefect.io logo
Title
s

Sandeep Aggarwal

08/27/2020, 1:32 PM
Hello Team, Looks like
delete_flow_run
mutation is clashing with Hasura's auto-generated mutation schemas. I am self hosting Prefect and as part of data retention policy, need to cleanup old data objects. I am using below mutation to cleanup old flow/task runs:
mutation($created_before: timestamptz) {
            delete_flow_run(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_flow_run_state(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_log(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_task_run(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_task_run_state(where: {created: {_lt: $created_before}}) {
                affected_rows
            }
        }
The request fails with below error:
2020-08-27T12:40:17.586Z {"message":"Unknown argument \"where\" on field \"delete_flow_run\" of type \"Mutation\".","locations":[{"line":3,"column":37}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
2020-08-27T12:40:17.586Z {"message":"Cannot query field \"affected_rows\" on type \"success_payload\".","locations":[{"line":7,"column":9}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
2020-08-27T12:40:17.586Z {"message":"Field \"delete_flow_run\" argument \"input\" of type \"delete_flow_run_input!\" is required, but it was not provided.","locations":[{"line":3,"column":21}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
When I remove
delete_flow_run
from above mutation, everything works fine.
d

Dylan

08/27/2020, 1:54 PM
Hi @Sandeep Aggarwal, I have great news! You shouldn’t have to do this manually. The database is set to delete all dependent objects on cascade. So, as long as you delete the flow runs, all task runs, logs, etc will be deleted.
Try only deleting Flow Runs with that where clause
affected_rows
does look like something from Hasura’s schema, as our mutations only have
success
and
error
Does
affected_rows
appear in the schema of the Interactive API?
s

Sandeep Aggarwal

08/27/2020, 2:00 PM
Thanks @Dylan for quick response. I am referring hasura docs for autogenerated schemas: https://hasura.io/docs/1.0/graphql/core/mutations/delete.html
This runs fine via Hasura UI, however when I run it via client, it clashes with the one provided by prefect
d

Dylan

08/27/2020, 2:07 PM
That’s correct, we actually filter Hasura’s auto-generated schemas and compose mutations so that they work to achieve a specific goal across many tables
s

Sandeep Aggarwal

08/27/2020, 2:10 PM
Makes sense. The issue is that the prefect's mutation only accepts ID of flow run to be deleted. So in order to use this one, I will have to query all flow_runs and then delete them one by one. Is there any option to perform bulk delete?
d

Dylan

08/27/2020, 2:10 PM
Not at this time, but that’s a great feature request!
Would you mind opening an issue on the server repo?
s

Sandeep Aggarwal

08/27/2020, 2:14 PM
Sure
d

Dylan

08/27/2020, 2:15 PM
Thank you!
And just to be clear, is the above mutation working in the Hasura ui as you expected?
s

Sandeep Aggarwal

08/27/2020, 2:16 PM
Yup it works as expected.
d

Dylan

08/27/2020, 2:16 PM
Great 👍