Snowflake child task not running after parent is suspended and child resumed - snowflake-cloud-data-platform

I have a root task which starts at a specific time (ex. cron 15/5 6 * * * TZ) and continues running every 5 mins. It calls an SP which checks for certain criteria. Once all criteria is met, it suspends the root task and resumes the child task. But somehow the child task even after resuming is not running. I tried checking the docs but still didn't find any reason for child to be not running. Could someone help?
Also, The child task runs an SP which in turn resumes the root task and other dependent tasks (dependent on the child). But when I switch off the after clause in the child task def. and adds a schedule to run it, the SP which it calls resume the root task and sets it to run in the next 5 mins instead of setting the schedule for the next day, since current day's run is already suspended. Could anyone help on this too?

have you used this?
-- enable recursive resumption of dependent tasks
select system$task_dependents_enable('');

Related

How to stop a flink job at specified position

Say I have a flink job processing a data flow like 1, 2, control_flag, 3...
When control_flag is met, the job should be stopped with savepoint and the following messages 3... should neither be processed or dropped. When centern actions are taken outside the flink and the job is restarted from savepoint, the job should go on process the following messages.
However, if the job hangs with a sleeping loop inside the process operator to prevent the following messages to be processed, it can not be stopped with savepoint using flink api. So how do I stop the job at the position of control_flag and let the job to be restarted with the position next to it?
Some suggestions can be found here.
There are a few possible ways that it can be done, but I think since You want to keep state between the runs, the best idea would be to have an operator that :
If the flag stop_execution is false, processes data and outputs that for the downstream operators.
If the flag stop_execution is true, it adds the data it receives to list state.
If it receives the control_flag it emits side output meaning that job should be stopped.
Now it's up to You to listen to the side output, this can be either external service that reads data from Kafka and executes correct REST calls to stop given job or anything else You want.

Faulty running time from sp_WhoIsActive?

Question 1:
If I turn on stored procedure sp_WhoIsActive v11.17 (2016-10-18)
on my VM, I get at "dd hh:mm:ss:mss" column value 02 06:34:12.000.
What does it mean?
I think that my request is not running 2 days.
sp_whoisactive example
Question 2:
What means status: dormant?
Can you explain this status at context SQL SERVER statuses (suspended, runnable, running).
Question-1:
What does "dd hh:mm:ss:mss" column mean in sp_whoisactive?
dd hh:mm:ss:mss: It indicates the elapsed time of the process until it has been started.
For a sleeping session refers to the amount of time elapsed since login time.
Question-2:
*Can you explain this status at context SQL SERVER statuses (suspended, runnable, running).
Boost SQL Server Performance with Wait Statistics
• Running status indicates that the scheduled thread is currently
being processed by the CPU.
• Suspended status indicates that the assigned thread is waiting
for a resource to be available. Such as, if any thread wants to access
a data page that acquires an exclusive lock, it waits in the suspended
status until the exclusive lock is removed and then it can access the
page.
• Runnable status indicates that the thread is not waiting for any
resources, but the CPU still unable to process this task because it is
dealing with another task.

Snowflake - Task not running

I have created a simple task with the below script and for some reason it never ran.
CREATE OR REPLACE TASK dbo.tab_update
WAREHOUSE = COMPUTE_WH
SCHEDULE = 'USING CRON * * * * * UTC'
AS CALL dbo.my_procedure();
I am using a snowflake trail enterprise version.
Did you RESUME? From the docs -- "After creating a task, you must execute ALTER TASK … RESUME before the task will run"
A bit of clarification:
Both the steps, while possibly annoying are needed.
Tasks can consume warehouse time (credits) repeatedly (e.g. up to
every minute) so we wanted to make sure that the execute privilege
was granted explicitly to a role.
Tasks can have dependencies and task trees (eventually DAGs)
shouldn't start executing as soon as one or more tasks are created.
Resume provides an explicit sync point when a data engineer can tell
us that the task tree is ready for validation and execution can
start at the next interval.
Dinesh Kulkarni
(PM, Snowflake)

SQL script stuck with status: runnable and wait: preemptive_os_reportevent

An Index Defrag was executed and was later on terminated. It impacted 2 other processes to long run. One process cancelled by itself and the other was terminated. While re-running I was checking the status from sys.dm_exec_requests and notice that on the last part of the query which will insert the data into a table, it is changing status from running to runnable: preemptive_os_reportevent, etc.. Later on, the job once again cancelled by itself.
I want to learn why is the script changing status like that? Is that expected? And if something else is causing it to long run, what else should I check?
Note: I was also checking other active scripts at the time it was running and none was using the same target table.
This has been resolved yesterday. Apparently, the syslogs was full and is prohibiting the script to write logs therefore it is stuck and can't complete. Feel free to add inputs if you have some.

Run SQL Agent Job in endless loop

There is an SQL Agent Job containing a complex Integration Services Package performing some ETL Jobs. It takes between 1 and 4 hours to run, depending on our data sources.
The Job currently runs daily, without problems. What I would like to do now is to let it run in an endless loop, which means: When it's done, start over again.
The scheduler doesn't seem to provide this option. I found that it would be possible to use the steps interface to go to step one after the last step is finished, but there's a problem using that method: If I need to stop the job, I would need to do that in a forceful way. However I would like to be able to let the job stop after the next iteration. How can I do that?
Thanks in advance for any help!
Since neither Martin nor Remus created an answer, here is one so the question can be accepted.
The best way is to simply set the run frequency to a very low value, like one minute. If it is already running, a second instance will not be created. If you want to stop the job after the current run, simply disable the schedule.
Thanks!
So you want that when you want to stop the job, after the running iteration, it should stop - if I am getting you correctly.
You can do one thing here.
Have one table for configuration which is having boolean value.
Add one step into the job. i.e. Before iteration, check the value from table. If it's true, then only run the ETL packages.
So, each time it finds its true, it'll follow endless loop.
When you want to stop the job, set that value in table to false.
When the current job iteration completes, it'll go to find the value from your table, will find it false, and the iteration will stop.
you can always set the "on success" action to go to step one, creating an endless loop, but as you said, if you want to stop the job you'll have to force it.
Other than that, an simple control table on the database with a status and a second job that queries this table and fires your main job depending on the status. Coupe of possible architectures here, just pick the one that suits you better
You could use service broker within the database. The job you need to run can be started by queuing a 'start' message and when it finishes it can send itself a message to start again.
To pause the process you can just deactivate the queue processor.

Resources