Skip to content

Commit 171c773

Browse files
authored
Manually recreating old PR (#21677)
1 parent b251e4a commit 171c773

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/content/docs/durable-objects/reference/durable-objects-migrations.mdx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,8 @@ transferred_classes = [{from = "DurableObjectExample", from_script = "OldWorkerS
275275
Note that `.toml` files do not allow line breaks in inline tables (the `{key = "value"}` syntax), but line breaks in the surrounding inline array are acceptable.
276276
:::
277277

278-
{/* ## Examples of Durable Object migration
279-
280-
To illustrate an example migrations workflow, the `DurableObjectExample` class can be initially defined with:
281-
282-
<WranglerConfig>
283-
284-
```toml
285-
# Creating a new Durable Object class
286-
[[migrations]]
287-
tag = "v1" # Migration identifier. This should be unique for each migration entry
288-
new_sqlite_classes = ["DurableObjectExample"] # Array of new classes
289-
```
290-
291-
</WranglerConfig>
292-
293-
You can rename the `DurableObjectExample` class to `UpdatedName` and delete an outdated `DeprecatedClass` entirely. You can create separate migrations for each operation, or combine them into a single migration as shown below. */}
294-
295-
296278
You cannot enable a SQLite storage backend on an existing, deployed Durable Object class, so setting `new_sqlite_classes` on later migrations will fail with an error. Automatic migration of deployed classes from their key-value storage backend to SQLite storage backend will be available in the future.
279+
280+
:::caution[Important]
281+
Durable Object migrations are atomic operations and cannot be gradually deployed. To provide early feedback to developers, new Worker versions with new migrations cannot be uploaded. Refer to [Gradual deployments for Durable Objects](/workers/configuration/versions-and-deployments/gradual-deployments/#gradual-deployments-for-durable-objects) for more information.
282+
:::

src/content/docs/workers/configuration/versions-and-deployments/gradual-deployments.mdx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ curl -s https://example.com -H 'Cloudflare-Workers-Version-Overrides: my-worker-
197197

198198
## Gradual deployments for Durable Objects
199199

200-
Due to [global uniqueness](/durable-objects/platform/known-issues/#global-uniqueness), only one version of each [Durable Object](/durable-objects/) can run at a time. This means that gradual deployments work slightly differently for Durable Objects.
200+
To provide [global uniqueness](/durable-objects/platform/known-issues/#global-uniqueness), only one version of each [Durable Object](/durable-objects/) can run at a time. This means that gradual deployments work slightly differently for Durable Objects.
201201

202-
When you create a new gradual deployment for a Durable Object Worker, each Durable Object is assigned a Worker version based on the percentages you configured in your [deployment](/workers/configuration/versions-and-deployments/#deployments). This version will not change until you create a new deployment.
202+
When you create a new gradual deployment for a Worker with Durable Objects, each Durable Object is assigned a Worker version based on the percentages you configured in your [deployment](/workers/configuration/versions-and-deployments/#deployments). This version will not change until you create a new deployment.
203203

204204
![Gradual Deployments Durable Objects](~/assets/images/workers/platform/versions-and-deployments/durable-objects.png)
205205

@@ -225,13 +225,25 @@ This is only an example, so the versions assigned to your Durable Objects may be
225225
- The Durable Object will only be [reset](/durable-objects/observability/troubleshooting/#durable-object-reset-because-its-code-was-updated) when it is assigned a different version, so each Durable Object will only be reset once in this example.
226226

227227
:::note
228-
229-
Typically, your Durable Object Worker will define both your Durable Object class and the Worker that interacts with it. In this case, you cannot deploy changes to your Durable Object and its Worker independently.
228+
Typically, a Worker bundle will define both the Durable Object class and a Worker that interacts with it. In this case, you cannot deploy changes to your Durable Object and its Worker independently.
230229

231230
You should ensure that API changes between your Durable Object and its Worker are [forwards and backwards compatible](/durable-objects/platform/known-issues/#code-updates) whether you are using gradual deployments or not. However, using gradual deployments will make it even more likely that different versions of your Durable Objects and its Worker will interact with each other.
232-
233231
:::
234232

233+
### Migrations
234+
235+
Versions of Worker bundles containing new Durable Object migrations cannot be uploaded. This is because Durable Object migrations are atomic operations. Durable Object migrations can be deployed with the following command:
236+
237+
```sh
238+
npx wrangler versions deploy
239+
```
240+
241+
To limit the blast radius of Durable Object migration deployments, migrations should be deployed independently of other code changes.
242+
243+
To understand why Durable Object migrations are atomic operations, consider the hypothetical example of gradually deploying a delete migration. If a delete migration were applied to 50% of Durable Object instances, then Workers requesting those Durable Object instances would fail because they would have been deleted.
244+
245+
To do this without producing errors, a version of the Worker which does not depend on any Durable Object instances would have to have already been rolled out. Then, you can deploy a delete migration without affecting any traffic and there is no reason to do so gradually.
246+
235247
## Observability
236248

237249
When using gradual deployments, you may want to attribute Workers invocations to a specific version in order to get visibility into the impact of deploying new versions.

0 commit comments

Comments
 (0)