---
title: Distributed Tasks
slug: 6CGCdQ8ZlPF3HuchxFQ7C
description: Ensure data integrity and performance with rebuild tasks and data checks in Ocient.
docTags: 
createdAt: Fri Jul 22 2022 13:25:52 GMT+0000 (Coordinated Universal Time)
updatedAt: Wed Apr 22 2026 21:07:21 GMT+0000 (Coordinated Universal Time)
---

You can manage distributed tasks in the Ocient® System. These tasks are processes that execute in the background to keep the system running smoothly and efficiently. These DDL commands create tasks to rebuild damaged or missing segment data and check data integrity.&#x20;

For information on managing tasks, see [Manage Distributed Tasks](<./././Database Administration/Manage Distributed Tasks.md>).

## CREATE TASK

Launches a new task. &#x20;

**Privileges**

To create any task, you must have the System Administrator role, which has the `UPDATE` privileges on the system.

**Syntax**

```sql
CREATE TASK [ task_name ]
    TYPE { rebuild | check_disk | rebalance }
    [ LOCATION { SYSTEM | CLUSTER cluster_name | NODE node_name } ]
    [ OPTIONS task_option_map [, ... ] ]
```

To create a task, you must specify a task type `TYPE`:&#x20;

- [rebuild](./#rebuild--task) — Reconstruct data segments by using erasure-coded data in the same segment group.
- [check\_disk](./#checkdisk--task) — Verify segments on a node by computing checksums.
- [rebalance](./#rebalance--task) — Distribute data evenly across disks in the system.

You can also optionally specify a location using the `LOCATION` keyword to execute the task. Supported values include:

- `SYSTEM` — Targets all segments in the system. If you do not specify the `LOCATION` keyword, `SYSTEM` is the default value.&#x20;
- `CLUSTER` — Targets a specific cluster.&#x20;
- `NODE` — Targets a specific node.&#x20;

| **Parameter**     | **Data Type**   | **Description**                                                                                                                                                                                                                            |
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `task_name`       | String          | Optional.<br /><br />The identifier for the task.                                                                                                                                                                                          |
| `TYPE`            | String          | Required. Specifies the type of the distributed task to create. Supported tasks are: <br /><br />`rebuild` — Rebuild task<br />`check_disk` — Check disk task<br />`rebalance` — Rebalance task<br /><br />Task names are case sensitive.  |
| `node_name`       | String          | This argument is required only if your task targets a node with the `LOCATION NODE` keywords.<br /><br />The name of a specific node for the task to target.                                                                               |
| `cluster_name`    | String          | This argument is required only if your task targets a cluster with the `LOCATION CLUSTER` keywords.<br /><br />The name of a specific cluster for the task to target.                                                                      |
| `task_option_map` | Key-value pairs | Optional. A comma-separated list of task-specific options in key-value pair format `key = value`.                                                                                                                                          |

### `rebuild` Task

Performing a rebuild segment operation reconstructs data segments by using erasure-coded data in the same segment group. This task allows the system to restore segments that are in the damaged `DAMAGED` or missing `MISSING` status to full performance. For details on rebuild tasks, see [Guide to Rebuilding Segments](<./././System Administration/Maintenance Overview/Guide to Rebuilding Segments.md>).&#x20;

:::hint{type="info"}
The `rebuild` task supports only the `SYSTEM` and `CLUSTER` locations. If you attempt the rebuild task on the node, the system returns an error.

To rebuild a single node, use the cluster location with the `LOCATION CLUSTER` keywords. Include the name of the node you want to rebuild as one of the key-value options.&#x20;
:::

`rebuild`**&#x20;Options (**`task_option_map`**)**

The rebuild task supports these options. You must specify these options as a comma-separated list of key-value pairs.

| **Option Key**   | **Value Type** | **Description**                                                                                                                              |
| ---------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `node`           | String         | Limits the rebuild operation to only segments on the specified node.                                                                         |
| `segment_groups` | List           | Limits the rebuild operation to the specified segment group identifiers. Specify this option as a bracketed list, e.g., `[ id1, id2, ... ]`. |
| `table_id`       | String         | Limits the rebuild to segment groups belonging to a specific table identifier.                                                               |

**Examples**

**Rebuild All Segments on the System**

This example performs a system-wide rebuild task.

```sql
CREATE TASK TYPE rebuild LOCATION SYSTEM;
```

**Rebuild Segments on the Specific Table**

This example rebuilds all segments on a system for the specified table with the table identifier `529a2e9d-d06c-46cd-a93b-624d3bed1c08`.

```sql
CREATE TASK TYPE rebuild OPTIONS table_id = '529a2e9d-d06c-46cd-a93b-624d3bed1c08';
```

**Rebuild Segments on the Specific Cluster**

This example rebuilds segments on the Foundation cluster `my_lts_cluster1`.

```sql
CREATE TASK TYPE rebuild LOCATION CLUSTER my_lts_cluster1;
```

**Rebuild Segments on the Specific Node**

This example rebuilds segments on the Foundation Node `my_node1` in the Foundation Cluster `my_lts_cluster1`.

```sql
CREATE TASK TYPE rebuild LOCATION CLUSTER my_lts_cluster1 OPTIONS node = 'my_node1';
```

**Rebuild the Specific Segment Group**

This example rebuilds segments in the segment group with the identifier `53` in the Foundation Cluster `my_lts_cluster1`.

```sql
CREATE TASK TYPE rebuild LOCATION CLUSTER my_lts_cluster1 OPTIONS segment_groups = [ 53 ];
```

**Create a Named Task**

This example creates the rebuild task named `my_rebuild_task` in the Foundation Cluster `my_lts_cluster1`.

```sql
CREATE TASK my_rebuild_task TYPE rebuild LOCATION CLUSTER my_lts_cluster1;
```

### `check_disk` Task

The `check_disk` task verifies the integrity of data segments on storage nodes by computing checksums. The task compares stored checksums with recomputed ones to detect disk corruption.&#x20;

`check_disk`**&#x20;Options (**`task_option_map`**)**

The `check_disk` task supports these options. You must specify these options as a comma-separated list of key-value pairs.

| **Option Key**   | **Value Type** | **Description**                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fix`            | Boolean        | If you set this option value to `true`, the task modifies the storage cluster state based on the checksum result. For example, if the task finds a segment that fails the checksum, the task sets its segment state to `DAMAGED`.<br /><br />Otherwise, the task reports any segments that fail the checksum, but it does not alter segment states.<br /><br />The default value is `false`. |
| `sample`         | Boolean        | If you set this option value to `true`, the task checks only a sample of data in each segment.<br /><br />The default value is `false`.                                                                                                                                                                                                                                                      |
| `only_unhealthy` | Boolean        | If you set this option value to `true`, the task checks only segments that are not in the `INTACT` state.<br /><br />The default value is `false`.                                                                                                                                                                                                                                           |
| `storage_ids`    | List           | This option limits the `check_disk` task to only a specific list of storage identifiers.  Specify these storage identifiers as a bracketed list, e.g., `[ 'id1', 'id2', ... ]`.                                                                                                                                                                                                              |

**Examples**

**Perform Checksum on the Specific Node**

This example computes the checksum on all segments on storage node `my_node1`.

```sql
CREATE TASK TYPE check_disk LOCATION NODE 'my_node1';
```

**Perform a Checksum on the Specific Cluster**

This example computes a checksum for a sample of blocks in each segment of the storage cluster `my_lts_cluster1` using the `sample = true` key-value pair.

```sql
CREATE TASK TYPE check_disk LOCATION CLUSTER my_lts_cluster1 OPTIONS sample = true;
```

**Compute Checksum on the Specific Storage Identifier**

This example computes a checksum for the segment with the storage identifier `529a2e9d-d06c-46cd-a93b-624d3bed1c08` on the storage node `my_node1`.

```sql
CREATE TASK TYPE check_disk LOCATION NODE 'my_node1' OPTIONS storage_ids = [ '529a2e9d-d06c-46cd-a93b-624d3bed1c08' ];
```

### `rebalance` Task&#x20;

Rebalancing evenly distributes data across disks in the system. Execute this task if data is not properly balanced across the system, such as after adding nodes or drives.&#x20;

For details on performing a `rebalance` task, see [Expand and Rebalance System](<./././System Administration/Maintenance Overview/Expand and Rebalance System.md>).&#x20;

:::hint{type="info"}
The `rebalance` task supports only `SYSTEM` and `CLUSTER` locations. If you attempt the rebalance task on a node, the system returns an error.
:::

**Example**

This example performs a rebalance task across all foundation clusters.

```sql
CREATE TASK TYPE rebalance;
```

## CANCEL TASK 

Cancels a running task. 

**Privileges**

To cancel a task, you must be assigned the System Administrator role. 

**Syntax**

```sql
CANCEL TASK ('task_name' | 'task_id')
```

| **Parameter** | **Data Type** | **Description**                                                                                                                                                                                                                                                                                                                                       |
| ------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `task_name`   | string        | The name specified on task creation. This applies only if an optional name was created for the task.                                                                                                                                                                                                                                                  |
| `task_id`     | string        | The unique identifier for the task in the system tables. <br />For rebuild tasks, you can find the unique identifier in the [sys.result\_cache](<././System Catalog Reference/System Catalog.md>) table.<br />For check disk tasks, you can find the unique identifier in the [sys.subtasks](<././System Catalog Reference/System Catalog.md>) table. |

**Example** 

Cancel a task named `my_task`.

```sql
CANCEL TASK 'my_task';
```

## Related Links

[System Catalog](https://docs.ocient.com/system-catalog)

[Guide to Rebuilding Segments](<./././System Administration/Maintenance Overview/Guide to Rebuilding Segments.md>)



