Home / Repstance User Guide / DATA COMPARISON / Start/Stop Task

Start/Stop Task

Start and Stop the Task using “repcli”

The "compare run" command is used to start the comparison task. The syntax is

repcli compare run capture=capture_id taskname=task_name mode=0|1|2|3 tables=list_of_the_tables

The parameters are:

  • capture - ID of the Capture Process
  • taskname - Name of the task
  • mode - Run mode. The possible values are:
    • 0 - Default. Resume validation task if it was stopped, otherwise start it from scratch
    • 1 - Restart the task from scratch
    • 2 - Run the task in “incremental” mode to compare the data that has only been changed since the last run (it needs the trail files of the Capture Process, see the Note below)
    • 3 - Repair the data. Reload the rows that the last run has found different or missing in the Target database (see “Repair the data” below)
  • tables - comma separated list of the tables to be processed by the command. Each table is specified in the schema_name.table_name format, as it is named in the Source database (the names are case-sensitive, the “%” symbol is not supported). The other tables of the task are not changed. If the parameter is not specified, or none of the names matches a table, all the tables of the task are processed. In the repair mode (mode=3) the list limits only the second comparison: every table of the task that has Failed or Missed Rows is repaired

Note - the only one task can be run at the time for the process

Note - the incremental mode (mode=2) reads the changes from the trail files of the Capture Process. The Apply Process deletes the trail files after it has applied them, unless its parameter “cleanuptrail” keeps them (0 - delete once applied, the default; a number - keep them for that number of days; -1 - never delete). If a trail file that is needed has been deleted, the command fails with an error that names the file, for example “open trail/trdemo_cap00000012: no such file or directory”. In this case run the task with mode=1, and keep the trail files for longer than the time between two runs if the incremental mode is used regularly.

The "stop" command is used to stop the task that is currently running. The stopped task can be resumed later (see mode=0 of the "run" command). The command syntax is:

repcli compare stop capture=capture_id 

Repair the data

When the comparison has found rows that are different (“Failed Rows”) or missing (“Missed Rows”) in the Target database, run the task in the repair mode. It brings these rows in line with the Source database and does not touch the other rows:

repcli compare run capture=capture_id taskname=task_name mode=3

The command returns at once. Use the “compare status” command to follow the repair.

The repair is done in the following steps:

  1. The Capture Process reads from the Source database the rows, whose keys the last run of the task has saved as failed or missing (all the columns of the rows).
  2. The rows are delivered to the Apply Process that has reported them. The Apply Process merges the rows into the Target table by the key: a missing row is inserted, a row that differs is updated.
  3. When the Capture Process has reloaded the tables, the task compares the repaired rows once more. The new result replaces the previous result of the table: the rows that are still different are shown again as the Failed or Missed Rows.

While the Capture Process reloads the rows the status of the task is “Waiting for Capture to Reload the Tables: [table names]”.

The repair:

  • needs the Capture Process and the Apply Process to be running: the task is completed when the Apply Process has applied the rows and compared them;
  • merges the rows by the primary key or the unique index of the table, so it must not be used for a table that has none (for example a table that is compared by the “keys” parameter);
  • repairs only the rows that the last run has found: when the task compares a part of the data (the “deep” parameter is less than 100) the other rows are neither checked nor repaired;
  • reads the rows from the Source database at the time of the repair: a row changed since the comparison is loaded with its current values, a row deleted from the Source database is not loaded;
  • does not delete the rows that exist only in the Target database, the comparison does not report them.

Note – The modes 0 and 1 start the comparison from scratch and discard the previous result. Run the repair before the next run of the task.

Note – If the repair of a table fails, the error is registered in the incidents and in the log of the Capture Process, and the result of the table in the report does not change. Check them if the status is the same after the repair.

Example

Repair the rows found by the last run of the “NewTask” task:

repcli compare run capture=2 taskname=NewTask mode=3

The command output:

Completed: [Command has been sent. Use [compare status] command to monitor the process]

While the Capture Process reloads the rows, “compare status” shows:

Capture 2: cap2, Status: (RUN) Waiting for Capture to Reload the Tables: [dbo.FactProductInventory], TaskName: NewTask

REST API

Run the task:

  • Endpoint: https://repstance_url/compare/run
  • Method: POST
  • Header:
    • Content-Type: application/json
    • X-Token: token
  • Body:
    {
      "capture_id":id_of_the_capture_process,
      "name":"name_of_the_task",
      "run":1,
      "mode":0|1|2|3,
      "tablelist":["table1", "table2", …]
    }

The “mode” value 3 repairs the rows that the last run of the task has found (see “Repair the data” above). The “tablelist” element is optional: it is the list of the tables to be processed (see the “tables” parameter of the repcli command).

Stop the task:

  • Endpoint: https://repstance_url/compare/run
  • Method: POST
  • Header:
    • Content-Type: application/json
    • X-Token: token
  • Body:
    {
      "capture_id":id_of_the_capture_process,
      "run":0
     }

Web UI

In the Web UI tasks are run and stopped in the “Compare” window of the Capture Process (click “Compare” on the card of the Capture Process). Select the tab of the task and click “Run”. The dialog offers the run modes that fit the state of the task:

Web UI: Run dialog of a finished task with Full Validation selected, the Run button highlighted
 
  • “Full Validation” compares the tables from the start and replaces the previous result (mode=1). A task that has never been run offers only this mode.
  • “Resume” goes on from the point where a stopped task ended (mode=0).
  • “Incremental” compares only the data that has changed since the last run (mode=2). It is offered when all the tables of the task are complete. It reads the changes from the trail files of the Capture Process, so it fails when the Apply Process has already deleted them (see the Note above and Tasks Control).

To run only some of the tables, untick the other tables of the report before you click “Run”. The comparison runs on the server, so you can close the window and come back later; click “Refresh” in the report, or tick “Auto refresh”, to follow the progress.

To stop a running task click “Stop”, which takes the place of “Run”. There is no confirmation. A stopped task can be resumed later with “Resume”:

Web UI, task deep_check running with 574 of 3697 chunks captured, the Stop button highlighted
 

The “Repair” button of the same window repairs the failed and the missed rows of the ticked tables (mode=3, see “Repair the data” above). All the modes, the selection of the tables, the report and the repair are described with pictures in Tasks Control.

Prev page:

Create Task

Next page:

Show Task