mirror of https://github.com/citusdata/citus.git
90 lines
2.9 KiB
Plaintext
90 lines
2.9 KiB
Plaintext
--
|
|
-- TASK_TRACKER_ASSIGN_TASK
|
|
--
|
|
\set JobId 401010
|
|
\set SimpleTaskId 101101
|
|
\set RecoverableTaskId 801102
|
|
\set SimpleTaskTable lineitem_simple_task
|
|
\set BadQueryString '\'SELECT COUNT(*) FROM bad_table_name\''
|
|
\set GoodQueryString '\'SELECT COUNT(*) FROM lineitem\''
|
|
\set SelectAll 'SELECT *'
|
|
-- We assign two tasks to the task tracker. The first task simply executes. The
|
|
-- recoverable task on the other hand repeatedly fails, and we sleep until the
|
|
-- task tracker stops retrying the recoverable task.
|
|
SELECT task_tracker_assign_task(:JobId, :SimpleTaskId,
|
|
'COPY (SELECT * FROM lineitem) TO '
|
|
'''base/pgsql_job_cache/job_401010/task_101101''');
|
|
task_tracker_assign_task
|
|
---------------------------------------------------------------------
|
|
|
|
(1 row)
|
|
|
|
SELECT task_tracker_assign_task(:JobId, :RecoverableTaskId, :BadQueryString);
|
|
task_tracker_assign_task
|
|
---------------------------------------------------------------------
|
|
|
|
(1 row)
|
|
|
|
-- After assigning the two tasks, we wait for them to make progress. Note that
|
|
-- these tasks get scheduled and run asynchronously, so if the sleep interval is
|
|
-- not enough, the regression tests may fail on an overloaded box.
|
|
SELECT pg_sleep(3.0);
|
|
pg_sleep
|
|
---------------------------------------------------------------------
|
|
|
|
(1 row)
|
|
|
|
SELECT task_tracker_task_status(:JobId, :SimpleTaskId);
|
|
task_tracker_task_status
|
|
---------------------------------------------------------------------
|
|
6
|
|
(1 row)
|
|
|
|
SELECT task_tracker_task_status(:JobId, :RecoverableTaskId);
|
|
task_tracker_task_status
|
|
---------------------------------------------------------------------
|
|
5
|
|
(1 row)
|
|
|
|
COPY :SimpleTaskTable FROM 'base/pgsql_job_cache/job_401010/task_101101';
|
|
SELECT COUNT(*) FROM :SimpleTaskTable;
|
|
count
|
|
---------------------------------------------------------------------
|
|
12000
|
|
(1 row)
|
|
|
|
SELECT COUNT(*) AS diff_lhs FROM ( :SelectAll FROM :SimpleTaskTable EXCEPT ALL
|
|
:SelectAll FROM lineitem ) diff;
|
|
diff_lhs
|
|
---------------------------------------------------------------------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT COUNT(*) As diff_rhs FROM ( :SelectAll FROM lineitem EXCEPT ALL
|
|
:SelectAll FROM :SimpleTaskTable ) diff;
|
|
diff_rhs
|
|
---------------------------------------------------------------------
|
|
0
|
|
(1 row)
|
|
|
|
-- We now reassign the recoverable task with a good query string. This updates
|
|
-- the task's query string, and reschedules the updated task for execution.
|
|
SELECT task_tracker_assign_task(:JobId, :RecoverableTaskId, :GoodQueryString);
|
|
task_tracker_assign_task
|
|
---------------------------------------------------------------------
|
|
|
|
(1 row)
|
|
|
|
SELECT pg_sleep(2.0);
|
|
pg_sleep
|
|
---------------------------------------------------------------------
|
|
|
|
(1 row)
|
|
|
|
SELECT task_tracker_task_status(:JobId, :RecoverableTaskId);
|
|
task_tracker_task_status
|
|
---------------------------------------------------------------------
|
|
6
|
|
(1 row)
|
|
|