Skip to content

feat(dynamodb)!: default to ClusterOptions.ServiceId, and refuse to start over unmigrated empty-ServiceId state - #11353

Draft
Laurianti wants to merge 12 commits into
dotnet:mainfrom
Laurianti:dynamodb-service-id-default
Draft

Laurianti wants to merge 12 commits into
dotnet:mainfrom
Laurianti:dynamodb-service-id-default

Conversation

@Laurianti

@Laurianti Laurianti commented Sep 26, 2026 •

Copy link
Copy Markdown

Builds on #11352, whose commits this branch includes; the changes of this PR alone: Laurianti/orleans@dynamodb-service-id...dynamodb-service-id-default

Problem

With #11352, an empty DynamoDBStorageOptions.ServiceId still stays empty unless UseClusterServiceId is set, so a new deployment still gets keys starting with an underscore, unlike every other grain storage provider.

Solution

UseClusterServiceId left unset now means ClusterOptions.ServiceId. This is a breaking change for deployments that never set ServiceId, and it is made so that it cannot hide their state: when the table records the empty ServiceId or holds state written with it, the provider fails to start, with a message that names both ways forward.

Table UseClusterServiceId unset false true
key format recorded as ClusterServiceId or MigratingToClusterServiceId ClusterOptions.ServiceId; a recorded migration goes on fails to start, as in #11352 ClusterOptions.ServiceId
key format recorded as EmptyServiceId fails to start empty ServiceId, with a warning ClusterOptions.ServiceId, and with MigrateLegacyKeys the state is moved
no record, and no key starting with an underscore ClusterOptions.ServiceId empty ServiceId, with a warning ClusterOptions.ServiceId
no record, and keys starting with an underscore fails to start empty ServiceId, with a warning ClusterOptions.ServiceId, and with MigrateLegacyKeys the state is moved

A table that records EmptyServiceId stops the provider even when it holds no such state yet: the silos that recorded it, running #11352, may still be writing those keys, and no scan sees what they write after it. For a table without a record, the provider scans for keys starting with an underscore, other than the key format record, with consistent reads in pages of 100, stopping at the first match (AnyAsync, a new internal method of the shared DynamoDBStorage). A table without such keys is read in full once: the record written afterwards skips the scan on the next starts. State written with an explicit ServiceId does not stop the provider, unless that ServiceId starts with an underscore, since the two cannot be told apart; the docs say to set UseClusterServiceId explicitly then. A silo from before #11352 neither reads nor writes the key format record, so an upgrade straight from such a version stops those silos first or sets UseClusterServiceId explicitly; the docs say so.

The startup warning now appears only when UseClusterServiceId is false, and no longer announces a future default.

An explicit ServiceId works as before.

Fixes: #9971

Copilot AI lite review requested due to automatic review settings September 26, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues remain in option resolution, migration reliability and TTL preservation, and legacy-state tracking.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Updates DynamoDB grain storage to default empty ServiceId values to ClusterOptions.ServiceId, detect legacy state, and support migration.

Changes:

  • Adds legacy-key detection, migration, and startup safeguards.
  • Adds configuration options, binding, scan support, API updates, and documentation.
  • Adds key-format and migration tests.
File Reviewed changes and final findings
test/​Extensions/​Orleans.AWS.Tests/​StorageTests/​DynamoDBGrainStorageKeyFormatTests.cs Covers key formats and migration behavior.
src/​AWS/​Shared/​Storage/​DynamoDBStorage.cs Adds single-page table scanning.
src/​AWS/​Orleans.Persistence.DynamoDB/​Provider/​DynamoDBGrainStorage.cs Moderate (3 votes): retain migration markers until success. Moderate (1 vote): preserve legacy TTL. Moderate (1 vote): prevent unbounded legacy-read tracking.
src/​AWS/​Orleans.Persistence.DynamoDB/​Options/​DynamoDBStorageOptions.cs Moderate (3 votes): avoid requiring global ClusterOptions when resolving named options.
src/​AWS/​Orleans.Persistence.DynamoDB/​Hosting/​DynamoDBGrainStorageServiceCollectionExtensions.cs Moderate (1 vote): preserve keyed overrides while tolerating missing global ClusterOptions.
src/​AWS/​Orleans.Persistence.DynamoDB/​Hosting/​DynamoDBGrainStorageProviderBuilder.cs Nit (2 votes): add configuration-binding tests for the new options, including invalid values.
src/​api/​AWS/​Orleans.Persistence.DynamoDB/​Orleans.Persistence.DynamoDB.cs Updates the public API surface.
docs/​site/​src/​content/​docs/​grains/​grain-persistence/​dynamodb-storage.md Documents defaults and migration behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/AWS/Orleans.Persistence.DynamoDB/Options/DynamoDBStorageOptions.cs Outdated
Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Copilot AI review requested due to automatic review settings September 26, 2026 10:08
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 5c82f16 to f355054 Compare September 26, 2026 10:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical legacy-state race and ETag handling issues, plus TTL loss during migration, remain unresolved.

Review effort: Lite
Findings: 2 High severity

Open (2)
Resolved since last review (3)

Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Copilot AI review requested due to automatic review settings September 26, 2026 11:58
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from f355054 to 43107d4 Compare September 26, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two moderate correctness findings and related state-recovery guidance remain unresolved.

Review effort: Lite
Findings: None

Resolved since last review (2)

Copilot AI review requested due to automatic review settings September 26, 2026 12:55
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 43107d4 to 9f1007c Compare September 26, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved migration correctness and legacy-state detection issues could cause data loss or incorrect startup behavior.

Review effort: Lite
Findings: 1 High severity

Open (1)

Copilot AI review requested due to automatic review settings September 26, 2026 14:04
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 9f1007c to 7e3a7cd Compare September 26, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical clear/migration behavior and moderate legacy-state detection issues remain.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 26, 2026 17:19
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 7e3a7cd to 0babd4b Compare September 26, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate migration, cleanup, and concurrency issues remain.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Copilot AI review requested due to automatic review settings September 26, 2026 19:48
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 2c6d6c5 to 877471d Compare September 26, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Three unresolved moderate issues must be addressed before approval.

Review effort: Lite
Findings: None

Resolved since last review (1)

…ate read from the current key while migrating
Copilot AI review requested due to automatic review settings September 26, 2026 22:58
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 877471d to f4a861b Compare September 26, 2026 22:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two moderate review findings remain unresolved in the migration detection and transaction conflict handling.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Copilot AI review requested due to automatic review settings September 27, 2026 07:05
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from f4a861b to 34d0a6b Compare September 27, 2026 07:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Legacy-state detection must avoid colliding with valid underscore-prefixed ServiceId values.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Copilot AI review requested due to automatic review settings September 27, 2026 07:39
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 34d0a6b to 4115a7a Compare September 27, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The rollout documentation must clarify the safe compatibility path for deployments with older silos.

Review effort: Lite
Findings: None

Resolved since last review (1)

Copilot AI lite review requested due to automatic review settings October 3, 2026 08:09
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from 4115a7a to b13002e Compare October 3, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical mixed-version migration and ETag validation issues, plus an options fallback issue, remain unresolved.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)

Comment thread src/AWS/Orleans.Persistence.DynamoDB/Provider/DynamoDBGrainStorage.cs Outdated
Copilot AI lite review requested due to automatic review settings October 3, 2026 11:46
@Laurianti
Laurianti force-pushed the dynamodb-service-id-default branch from b13002e to 06d53ff Compare October 3, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two moderate issues remain in transaction error handling and malformed ETag parsing.

Review effort: Lite
Findings: None

Resolved since last review (3)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamoDBStorageOptions ServiceId default

2 participants