You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn/advanced/asynchronous_operations.md
+18-25Lines changed: 18 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -10,32 +10,29 @@ For example, updating the `filterableAttributes` index setting will require as m
10
10
11
11
Currently, these are Meilisearch's asynchronous operations:
12
12
13
-
- Updating index settings
14
-
- Adding documents to an index
15
-
- Updating documents in an index
16
13
- Creating an index
17
14
- Updating an index
18
15
- Deleting an index
19
16
- Updating index settings
20
17
- Adding documents to an index
21
18
- Updating documents in an index
22
19
- Deleting documents from an index
23
-
-[Creating a dump](#dumps)
20
+
- Creating a dump
24
21
25
22
## Understanding tasks
26
23
27
-
Most of Meilisearch's asynchronous operations belong to a category called "tasks". After you have requested an asynchronous operation, you can use the [task API](/reference/api/tasks.md) to find the detailed status of your request. To do so, you will need your task's `uid`.
24
+
All of Meilisearch's asynchronous operations belong to a category called "tasks". After you have requested an asynchronous operation, you can use the [task API](/reference/api/tasks.md) to find the detailed status of your request. To do so, you will need the task's unique identifier.
28
25
29
-
### Response
26
+
### Task API response
30
27
31
28
The response from the [task API](/reference/api/tasks.md) will always include the following fields in the stated order:
|`uid`| integer | The unique sequential identifier of the task |
36
-
|`indexUid`| string | The unique index identifier |
33
+
|`indexUid`| string | The unique index identifier (always `null` for dumps) |
37
34
|`status`| string | The status of the task. Possible values are `enqueued`, `processing`, `succeeded`, `failed`|
38
-
|`type`| string | The type of task. Possible values are `indexCreation`, `indexUpdate`, `indexDeletion`, `documentAddition`, `documentPartial`, `documentDeletion`, `settingsUpdate`, `clearAll`|
35
+
|`type`| string | The type of task. Possible values are `indexCreation`, `indexUpdate`, `indexDeletion`, `documentAdditionOrUpdate`, `documentPartial`, `documentDeletion`, `settingsUpdate`, `clearAll`, `dumpCreation`|
39
36
|`details`| object | Detailed information on the task payload |
40
37
|`error`| object | Error details and context. Only present when a task has the `failed` status |
41
38
|`duration`| string | The total elapsed time the task spent in the `processing` state, in ISO 8601 format |
@@ -47,17 +44,17 @@ If a task fails due to an error, all error fields will be appended to the task r
47
44
48
45
### Summarized task objects
49
46
50
-
All asynchronous operations return a summarized version of the [`task` object](#response). It contains the following fields in the stated order:
47
+
All asynchronous operations return a summarized version of [the full `task` object](#task-api-response). It contains the following fields in the stated order:
|`indexUid`| string | Unique index identifier (always `null` for dumps) |
56
53
|`status`| string | Status of the task. Value is `enqueued`|
57
54
|`type`| string | Type of task |
58
55
|`enqueuedAt`| string | Represents the date and time in the RFC 3339 format when the task has been `enqueued`|
59
56
60
-
You can use this `uid` to get more details on [the status of the task](/reference/api/tasks.md#get-task).
57
+
You can use this `taskUid` to get more details on [the status of the task](/reference/api/tasks.md#get-one-task).
61
58
62
59
### Task `status`
63
60
@@ -70,16 +67,16 @@ Task responses always contain a field indicating the request's current `status`.
70
67
71
68
### Examples
72
69
73
-
Suppose you add a new document to your instance using the [add documents endpoint](/reference/api/documents.md#add-or-replace-documents) and receive a `uid` in response.
70
+
Suppose you add a new document to your instance using the [add documents endpoint](/reference/api/documents.md#add-or-replace-documents) and receive a `taskUid` in response.
74
71
75
-
When you query the task endpoint using this `uid`, you see that it has been enqueued:
72
+
When you query the [get task endpoint](/reference/api/tasks.md#get-one-task) using this value, you see that it has been enqueued:
76
73
77
74
```json
78
75
{
79
76
"uid": 1,
80
77
"indexUid": "movies",
81
78
"status": "enqueued",
82
-
"type": "documentAddition",
79
+
"type": "documentAdditionOrUpdate",
83
80
"details": {
84
81
"receivedDocuments": 67493,
85
82
"indexedDocuments": null
@@ -98,7 +95,7 @@ Later, you check the request's status one more time. It was successfully process
98
95
"uid": 1,
99
96
"indexUid": "movies",
100
97
"status": "succeeded",
101
-
"type": "documentAddition",
98
+
"type": "documentAdditionOrUpdate",
102
99
"details": {
103
100
"receivedDocuments": 67493,
104
101
"indexedDocuments": 67493
@@ -117,7 +114,7 @@ Had the task failed, the response would have included an `error` object:
117
114
"uid": 1,
118
115
"indexUid": "movies",
119
116
"status": "failed",
120
-
"type": "documentAddition",
117
+
"type": "documentAdditionOrUpdate",
121
118
"details": {
122
119
"receivedDocuments": 67493,
123
120
"indexedDocuments": 0
@@ -137,16 +134,12 @@ Had the task failed, the response would have included an `error` object:
137
134
138
135
## Task workflow
139
136
140
-
1. When you make a task request, Meilisearch puts it in the task queue, sets the task's `status` to `enqueued` and returns a [`task` object](/learn/advanced/asynchronous_operations.md#response)
137
+
1. When you make an [asynchronous request](#which-operations-are-async), Meilisearch puts it in the task queue, sets the task's `status` to `enqueued` and returns a [summarized `task` object](/learn/advanced/asynchronous_operations.md#summarized-task-objects)
141
138
2. When your task reaches the front of the queue, Meilisearch begins working on it and changes the request `status` to `processing`
142
139
3. Once the task has completed processing, Meilisearch marks it as `succeeded`, if it was successful, or `failed`, if there was an error.
143
-
4. Tasks marked as `succeeded` or `failed` are not deleted and will remain visible in [the task list](/reference/api/tasks.md#get-all-tasks)
144
-
145
-
### Dumps
146
-
147
-
While dumps and tasks are both asynchronous operations, they use separate queues and behave differently. For instance, creating a new dump will freeze the task queue until the dump has been generated.
140
+
4. Tasks marked as `succeeded` or `failed` are not deleted and will remain visible in [the task list](/reference/api/tasks.md#get-tasks)
148
141
149
-
[You can read more about dumps in our dedicated guide.](/learn/advanced/dumps.md)
142
+
Tasks are processed in the order they were enqueued, with one exception: `dumpCreation`. Dumps are prioritized over all other tasks in the queue. Their task `uid` still reflects when they were enqueued relative to other tasks.
150
143
151
144
## Terminate Meilisearch while a task is being processed
152
145
@@ -156,8 +149,8 @@ Meilisearch's asynchronous tasks are atomic. This means that all operations conc
156
149
157
150
What happens to an asynchronous operation when Meilisearch is terminated changes depending on the request's `status`:
158
151
159
-
-`enqueued`: the task will remain enqueued and will be processed as usual once is restarted
160
-
-`processing`: there will be no consequences, since no part of the task has been committed to the database. After restarting, will treat the task as `enqueued`
152
+
-`enqueued`: the task will remain enqueued and will be processed as usual once Meilisearch has been restarted
153
+
-`processing`: there will be no consequences, since no part of the task has been committed to the database. After restarting, the task will be treated as `enqueued`
161
154
-`succeeded`: there will be no data loss since the request was successfully completed
162
155
-`failed`: the task failed and nothing has been altered in the database
A dump is a compressed file containing an export of your Meilisearch instance. It contains all your indexes, documents, and settings, but in a raw unprocessed form. A dump isn't an exact copy of your database—it is closer to a blueprint that allows you to create an identical dataset. A dump can be imported when launching Meilisearch, but be advised that it may take some time to index all the documents within.
3
+
A dump is a compressed file containing an export of your Meilisearch instance. It contains all your indexes, documents, and settings, but in a raw unprocessed form. A dump isn't an exact copy of your database—it is closer to a blueprint that allows you to create an identical dataset.
4
+
5
+
A dump can be imported when launching Meilisearch, but be advised that it may take some time to index.
4
6
5
7
## Creating a dump
6
8
7
9
To create a dump of your dataset, you need to use the appropriate HTTP route: [`POST /dumps`](/reference/api/dump.md#create-a-dump). The dump creation process is an asynchronous task that takes time proportional to the size of your dataset.
8
10
9
11
<CodeSamplesid="post_dump_1" />
10
12
11
-
The above code triggers a dump creation process. It also returns an object containing information about the dump:
13
+
The above code triggers a dump creation process. It also returns a [summarized task object](/learn/advanced/asynchronous_operations.md#summarized-task-objects) that you can use to check the status of your dump.
12
14
13
-
```
15
+
```json
14
16
{
15
-
"uid": "20200929-114144097",
16
-
"status": "in_progress",
17
-
"startedAt": "2020-09-29T11:41:44.392327Z"
17
+
"taskUid": 1,
18
+
"indexUid": null,
19
+
"status": "enqueued",
20
+
"type": "dumpCreation",
21
+
"enqueuedAt": "2022-06-21T16:10:29.217688Z"
18
22
}
19
23
```
20
24
21
-
You can use the returned `uid` (unique identifier indicating when the dump was triggered) to track its progress with the [get dump status route](/reference/api/dump.md#get-dump-status). The returned status could be:
22
-
23
-
-`in_progress`: Dump creation is in progress
24
-
-`failed`: An error occurred during dump process, and the task was aborted
25
-
-`done`: Dump creation is finished and was successful
25
+
In the below command, replace `1` with the `taskUid` returned by the previous command.
26
26
27
-
<CodeSamplesid="get_dump_status_1" />
27
+
<CodeSamplesid="get_task_1" />
28
28
29
-
The above code sample returns an object with the following details about the dump:
29
+
This command should return an object with detailed information about the dump operation:
30
30
31
-
```
31
+
```json
32
32
{
33
-
"uid": "20200929-114144097",
34
-
"status": "done",
35
-
"startedAt": "2020-09-29T11:41:44.392327Z",
36
-
"finishedAt": "2020-09-29T11:41:50.792147Z"
33
+
"uid": 1,
34
+
"indexUid": null,
35
+
"status": "succeeded",
36
+
"type": "dumpCreation",
37
+
"details": {
38
+
"dumpUid": "20220621-161029217"
39
+
},
40
+
"duration": "PT0.025872S",
41
+
"enqueuedAt": "2022-06-21T16:10:29.217688Z",
42
+
"startedAt": "2022-06-21T16:10:29.218297Z",
43
+
"finishedAt": "2022-06-21T16:10:29.244169Z"
37
44
}
38
45
```
39
46
40
-
After dump creation is finished, the dump file is added to the dump directory. By default, this folder is named `dumps` and can be found in the same directory as your Meilisearch binary. You can customize [this using the `--dumps-dir` configuration option](/learn/configuration/instance_options.md#dumps-destination). **If the dump directory does not already exist when the dump creation process is called, Meilisearch will create it.**
47
+
After dump creation is finished—when `status` is `succeeded`—the dump file is added to the dump directory. By default, this folder is named `dumps` and can be found in the same directory as your Meilisearch binary. You can customize [this using the `--dumps-dir` configuration option](/learn/configuration/instance_options.md#dumps-destination). **If the dump directory does not already exist when the dump creation process is called, Meilisearch will create it.**
41
48
42
49
If a dump file is visible in the file system, the dump process was successfully completed. **Meilisearch will never create a partial dump file**, even if you interrupt an instance while it is generating a dump.
43
50
44
-
::: note
45
-
Unlike [tasks](/learn/advanced/asynchronous_operations.md), dumps have no queue. **Meilisearch only processes one dump at a time.** If you attempt to create a dump while another dump is still processing, Meilisearch will throw an [error](/reference/api/error_codes.md#dump-already-processing).
46
-
47
-
Meilisearch does not process tasks during dump creation, but you can still add new requests to the task queue. This is also true for [snapshots](/learn/advanced/snapshots.md#snapshots).
48
-
:::
49
-
50
-
::: warning
51
-
If you restart Meilisearch after creating a dump, you will not be able to use the dumps endpoint to find out that dump's `status`. This has no effect on the dump file itself.
52
-
:::
53
-
54
51
## Importing a dump
55
52
56
53
When a dump is being imported, the API is not available to the task queue. As a result, no read or write operations can be performed until the importing process is complete.
57
54
58
-
Dumps in v0.20.0 and below are no longer compatible with the new versions. Before you start importing, check your [Meilisearch version](/reference/api/version.md#example) and proceed accordingly.
55
+
Dumps from v0.20.0 and below are no longer compatible with the new versions. Before you start importing, check your [Meilisearch version](/reference/api/version.md#example) and proceed accordingly.
59
56
60
57
::: note
61
-
We do not recommend using dumps from a new Meilisearch version to import an older version.
58
+
We do not recommend using dumps to migrate from a new Meilisearch version to an older one.
62
59
63
60
For example, you can import a dump from Meilisearch v0.21 into v0.22 without any problems. Importing a dump generated in v0.22 into a v0.21 instance, however, can lead to unexpected behavior.
64
61
:::
@@ -79,4 +76,4 @@ If you are using Meilisearch v0.20 or below, migration should be done in two ste
79
76
80
77
## Use cases
81
78
82
-
Dumps are used to restore your database after [updating Meilisearch](/learn/advanced/updating.md) or to copy your database to other Meilisearch instances without having to worry about their respective versions.
79
+
Dumps are used to restore your database after [updating Meilisearch](/learn/advanced/updating.md) or to copy your database to other Meilisearch instances without having to worry about their respective versions. For more on this subject, see a [comparison of snapshots and dumps](/learn/advanced/snapshots_vs_dumps.md).
0 commit comments