Skip to content

feat(streaming): replay retained stream history - #11076

Open
ReubenBond wants to merge 74 commits into
dotnet:mainfrom
ReubenBond:rb-feat-streaming-retained-history-replay
Open

ReubenBond wants to merge 74 commits into
dotnet:mainfrom
ReubenBond:rb-feat-streaming-retained-history-replay

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Problem

Persistent stream subscriptions need to resume from retained provider positions older than the live Orleans cache and transition continuously into live delivery.

Solution

Add a provider-neutral asynchronous replay cursor and receiver-owned replay manager with bounded admissions, pooled replay fragments, partition-order filtering, explicit retention failures, and atomic live-cache handoff.

Kinesis opens independent shard readers from retained arbitrary-precision sequence positions, renews iterators, shares shard read throttling, and validates stream/shard token identity while preserving the legacy serialized shard-sequence field. ADO.NET streaming uses schema version 3 with epoch-fenced, provider-visible replay leases whose safe watermarks protect cleanup across silos. SQL Server, PostgreSQL, and MySQL implement the same admission, renewal, release, cleanup, and hard-retention contract.

Event Hubs and Redis provide live-cache rewind. Their durable transport positions support receiver recovery independently from per-subscription retained-history replay.

Decomposition and final completion target

This PR is the final merge target which closes #756. It preserves the integrated retained-history implementation while smaller, release-ready prerequisites are extracted. Independent slices target main; human-merged predecessors are removed by rebasing. The final scope includes ADO.NET replay activation, cross-provider replay conformance, and complete user-facing guidance.

Slice Outcome Prerequisites / status
1. Pooled buffer ownership Generator, memory, and Event Hubs caches release stale buffer references after purge #11152 merged into main
2. Provider-encoded cache offsets Custom adapters position pooled cursors using provider-defined offsets #11153 merged into main; result-API migration supplied by #11230
3. Legacy token recovery Persisted legacy and provider tokens compare and resume consistently #11155 merged into main
4. Reusable checkpoint core Grain checkpointers share optimistic updates, coalescing, throttling, and flush recovery #11154 and #11227 merged into main
5. Publisher cleanup and pulling-agent lifecycle Defunct publishers and dropped clients are cleaned up; admitted work drains before shutdown #10532, #11260, and #11268 merged into main; newer producer-retirement protocol remains a coordinated #10588 prerequisite
6. Azure Table checkpoint adapter Existing Event Hubs facade uses the reusable checkpoint core and cancellation contract Core supplied by 4; adapter integration remains here
7. Kinesis checkpoint/token correctness Arbitrary-precision shard ordering and durable strict-after recovery 2, 3, 4 supplied by main; provider integration remains here
8. Generic live recovery pipeline Encoded-byte-bounded receiver/cache, safe contiguous progress, periodic reporting, and cancellation-safe lifecycle Current branch uses record-count cache bounds; newer byte accounting, overflow ownership, and associated foundation contracts remain in #10588
9. Kinesis live migration Production provider adopts the bounded generic live pipeline 7, 8; current integrated implementation is count-bounded
10. Generic retained replay Bounded asynchronous history readers/fragments, retention errors, and pinned live handoff 8; replay-specific implementation remains here
11. Kinesis retained replay Independent historical readers, shared shard throttle, and stable stream/shard identity 9, 10
12. ADO.NET immutable partition log Coherent SQL, query/runtime/options/API, and migration transition 4, 8; schema-v3 release boundary requires agreement with #10588
13. Final retained replay completion Fenced ADO.NET replay leases, protected cleanup, cross-provider conformance, and replay guidance #11076, after 10, 11, and 12

The first wave and intermediate provider PRs reference #756. This PR retains Closes #756 and reaches its final completion scope once the prerequisites and complete rewind/replay outcome are ready. Decomposition remains an agreed extraction sequence, with the current integrated branch preserving the source until each slice has a verified disposition.

Source preservation and current integration

Original source snapshot: aa2c36d0c3eb9de5c3279ba24d52b0b7c59818b5 against 81b4e84a0f771bd0930d3369295fa73b0363ca9c (57 commits, 133 files). Its embedded foundation ends at c1f1a89362e8d2b9d3c792801cd81d416b8a063a; that historical snapshot remains available for change accounting.

The current branch is rebased onto main at 9222be9a19196335e129e211718619f47bf73adc, including #10532, #11249, #11154, #11155, #11260, and #11268. It preserves prefetched recovery batches, admission/drain ownership, handshake request identities and generations, compatible drained-subscription progress, legacy cursor scheduling, and replay-specific stream/shard identity and live handoff.

The preparation fixes are isolated:

  • ad26902337: a heartbeat failure recorded during an in-flight ADO.NET replay read retains its original transient, ownership-loss, or retention classification, whether SQL observes cancellation or finishes successfully. Ordinary caller and shutdown cancellation retain cancellation semantics. Transient replay failures therefore reach cursor recreation from the established safe position.
  • 6876df9b17: quiet-partition scans wake progress-aware cursors while preserving matching-stream legacy scheduling; replay read errors use the captured handshake request ID. ADO.NET shutdown guidance describes checkpoint and replay-lease ownership.
  • c18042691b: ports the isolated Latest correction from feat(streaming)!: unify stream partition recovery #10588 commit 79e7864af6b44b847540c4bd78ca209e5faa5622. A new Latest cursor records its excluded partition prefix as safe scan progress; included deliveries and retries retain their checkpoint barrier. The four integration cases exercise this branch's explicit record-count capacity.
  • 0a8870ea10: regenerates the Event Hubs API surface for the integrated Azure Table cancellation overloads, using the repository GenAPI workflow.

Explicit residual slices and release decisions

The newer #10588 encoded-byte capacity, buffered-overflow ownership, and producer-initiated retirement protocols remain distinct integration prerequisites. Their port must preserve this branch's replay ownership, atomic handoff, current admission/drain guarantees, and handshake identities. #8273 shares the canonical foundation dependency and coordinates its provider integration separately.

ADO.NET currently has one consistent schema-v3 contract across runtime validation, all three SQL dialects, query keys, options, generated APIs, compatibility treatment, and migration documentation. Its implemented upgrade is a coordinated replacement: stop producers and consumers, export required payloads, replace streaming objects/query rows with the current scripts, verify version and replay keys, then restart.

The human release decision is whether the foundation and replay ship as one unreleased final schema transition or establish a separately released v2 boundary with an explicit staged migration. The current v3 replacement policy is preserved pending that agreement. SQL/runtime/ownership/checkpoint/cleanup behavior and replay lease activation form one coherent release unit; slices 12 and 13 can be combined to maintain that contract.

Each extracted slice carries its runtime behavior, regression coverage, generated API surface, scoped package compatibility treatment, and documentation. Contributor branches remain in their forks, and subsequent slices target updated main with explicit prerequisites.

Guarantees

  • Subscription start tokens are inclusive; acknowledged delivery tokens resume after the acknowledged record.
  • Historical readers scan the physical partition in order and attach to a pinned live cursor before replay state is released.
  • A Latest subscription attached to a populated cache excludes the current partition prefix. An empty-cache Latest cursor includes the first subsequently admitted record. Included deliveries constrain safe progress until successful delivery or intentional filtering.
  • Compatible, drained subscriptions advance with the queue read boundary; pending registrations, handshakes, deliveries, and recovery constrain checkpoint calculation to established progress.
  • Future positions recognized by the provider remain pending until the requested live position arrives. Native Kinesis record tokens identify already-published records, and invalid exact positions fail explicitly.
  • Delivery remains at least once across failures.
  • Expired retention, malformed positions, and invalid provider or partition identities surface as DataNotAvailableException.
  • Reader concurrency, pending admission, replay cache capacity, and read batch size are bounded per queue.
  • Shutdown drains admitted work before final progress, checkpoint, and receiver cleanup.

Closes #756

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 4, 2026 14:29

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

Several new/updated StreamSequenceToken types declare Orleans serialization field ids which overlap with their base type’s ids, which can break generated serialization and persisted token compatibility.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 3 High severity

New issues introduced by this change (3)
Severity Finding
High severity src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisSequenceToken.cs — KinesisSequenceToken declares additional Orleans-serialized members using [Id(0..2)], which…
High severity src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamSequenceToken.cs — AdoNetStreamSequenceToken uses [Id(0..2)] for its own members even though it inherits…
High severity src/​Orleans.Streaming/​Common/​PartitionedStreamSequenceToken.cs — The [Id] values on PartitionedStreamSequenceToken overlap with the base EventSequenceTokenV2 field…
What changed in this PR

This PR extends Orleans persistent streaming to support replaying retained stream history when a subscription start token falls outside the live in-memory cache, enabling a gap-free handoff from historical replay to live delivery. It introduces provider-neutral replay abstractions plus provider-specific implementations for Kinesis and the ADO.NET partitioned stream provider, along with updated docs and expanded conformance tests around token identity, ordering, and checkpoint/retention behavior.

Changes:

  • Add a provider-neutral async replay cursor model and supporting streaming/cache primitives (cursor progress, adapter-aware comparisons, pooled-cache purge behavior).
  • Implement retained-history replay support for Kinesis and update ADO.NET streaming to a partitioned, retention/lease-based replay model (plus new checkpoint store contracts).
  • Update documentation and add/adjust unit/provider tests to cover new token semantics, checkpoint contracts, eviction behavior, and replay expectations.
File Description
test/​Orleans.Streaming.Tests/​StreamingTests/​PubSubRendezvousGrainTests.cs Adds coverage for subscription-unregistered diagnostics emitted after state is cleared.
test/​Orleans.Streaming.Tests/​StreamingTests/​ClientStreamTestRunner.cs Adjusts dropped-client test flow to optionally assert delivery failure counts without forcing a default counter.
test/​Orleans.Streaming.Tests/​OrleansRuntime/​Streams/​PooledCacheBufferOwnershipTests.cs New tests validating pooled buffer behavior after purge-to-empty scenarios.
test/​Orleans.Streaming.Tests/​OrleansRuntime/​Streams/​EncodedOffsetPooledQueueCacheTests.cs New tests for adapter-aware cached-message searches using encoded offsets.
test/​Orleans.Streaming.Tests/​OrleansRuntime/​Streams/​CachedMessageBlockTests.cs Adds tests ensuring cache blocks clear payload references on remove/reset.
test/​Orleans.Streaming.Tests/​JsonConverters/​StreamingJsonConverterTests.cs Adds JSON round-trip coverage for partitioned stream sequence tokens.
test/​Orleans.Streaming.Tests/​Checkpointers/​StreamQueueCheckpointerTests.cs Adds numeric-boundary checkpoint persistence coverage.
test/​Orleans.Streaming.Tests/​Checkpointers/​ReusableStreamQueueCheckpointerTests.cs New tests for conditional checkpoint conflicts and retry semantics with versioned stores.
test/​Extensions/​Orleans.Streaming.Kinesis.Tests/​KinesisBatchContainerTests.cs Expands Kinesis batch/token tests (event index, ordering, legacy payload shape, recoverable adapter behavior).
test/​Extensions/​Orleans.Streaming.Kinesis.Tests/​KinesisAdapterTests.cs Adjusts Kinesis adapter test to validate cache cursor behavior using first observed tokens.
test/​Extensions/​Orleans.Streaming.Kinesis.Tests/​DynamoDBStreamQueueCheckpointerTests.cs Updates DynamoDB checkpointer tests for versioned checkpoint-store state.
test/​Extensions/​Orleans.Streaming.EventHubs.Tests/​EvictionStrategyTests/​EHPurgeLogicTests.cs Updates expectations for purge behavior when caches become empty.
test/​Extensions/​Orleans.Streaming.EventHubs.Tests/​EventHubSequenceTokenTests.cs New tests covering Event Hub token cross-version symmetry and ordering rules.
test/​Extensions/​Orleans.Streaming.EventHubs.Tests/​CheckpointerTests/​EventHubCheckpointerTests.cs Updates EventHub checkpointer tests for new signatures/inner state handling.
test/​Extensions/​Orleans.Streaming.EventHubs.Tests/​CheckpointerTests/​AzureTableStreamQueueCheckpointerContractTests.cs New contract tests for Azure Table checkpointer against the shared checkpointer test suite.
test/​Extensions/​Orleans.Redis.Tests/​Streaming/​RedisStreamSequenceTokenTests.cs New tests for Redis token equality/ordering and rejection of base tokens.
test/​Extensions/​Orleans.Redis.Tests/​Streaming/​RedisStreamBatchContainerTests.cs Adds CreateSequenceTokenForEvent coverage preserving Redis position metadata.
test/​Extensions/​Orleans.Azure.Tests/​UnitTestAzureTableDataManager.cs Updates test table init to pass cancellation tokens through.
test/​Extensions/​Orleans.AdoNet.Tests/​Streaming/​AdoNetStreamMessageStreamIdTests.cs New tests ensuring stored StreamId bytes + namespace boundary reconstruct correctly.
test/​Extensions/​Orleans.AdoNet.Tests/​Streaming/​AdoNetQueueAdapterTests.cs Updates ADO.NET adapter tests for partitioned provider behavior and new storage read paths.
test/​Extensions/​Orleans.AdoNet.Tests/​Streaming/​AdoNetQueueAdapterFactoryTests.cs Updates factory tests for rewindable behavior, shared receiver/cache registry, and failure handler settings.
test/​Extensions/​Orleans.AdoNet.Tests/​Streaming/​AdoNetClientStreamTests.cs Updates dropped-client test to rely on subscription-unregistered behavior without dead-letter counting.
test/​Extensions/​Orleans.AdoNet.Tests/​Streaming/​AdoNetBatchContainerTests.cs Updates message schema handling and adds JSON round-trip + recoverable adapter tests for ADO.NET tokens.
test/​Extensions/​Orleans.AdoNet.Tests/​StorageTests/​Relational/​RelationalStorageExtensionsTests.cs Updates relational storage extension tests to flow cancellation tokens.
test/​Benchmarks.AdoNet/​Streaming/​StreamPartitionAppendBenchmark.cs New benchmark for stream-partition append throughput under contention/payload/concurrency variation.
test/​Benchmarks.AdoNet/​Streaming/​MessageQueueingBenchmark.cs Removes older queueing benchmark superseded by partition append benchmark.
test/​Benchmarks.AdoNet/​Streaming/​MessageDequeueingBenchmark.cs Removes older dequeueing benchmark superseded by new partitioned model benchmarks.
src/​Redis/​Orleans.Streaming.Redis/​Streams/​RedisStreamSequenceToken.cs Updates token CreateSequenceTokenForEvent override and enforces comparable-type constraints in CompareTo.
src/​Orleans.Streaming/​QueueAdapters/​IQueueCacheCursorProgress.cs Adds new cursor progress interfaces used for safe contiguous partition progress tracking.
src/​Orleans.Streaming/​QueueAdapters/​IQueueCache.cs Updates delivery-progress doc semantics to “earliest safe contiguous partition position”.
src/​Orleans.Streaming/​QueueAdapters/​IAsyncQueueCacheCursor.cs Adds async cursor API + transient replay exception + MoveNext result enum for retained-history reads.
src/​Orleans.Streaming/​PubSub/​PubSubRendezvousGrain.cs Emits subscription-unregistered diagnostic when clearing state after removal.
src/​Orleans.Streaming/​PersistentStreams/​QueueStreamDataStructures.cs Adds per-subscription tracking for cursor start/safe-partition tokens and replay availability.
src/​Orleans.Streaming/​PersistentStreams/​Options/​PersistentStreamProviderOptions.cs Adds configurable delivery progress update interval for pulling agents.
src/​Orleans.Streaming/​MemoryStreams/​MemoryPooledCache.cs Clears current buffer reference when purge leaves cache empty.
src/​Orleans.Streaming/​JsonConverters/​EventSequenceTokenJsonConverter.cs Extends converter to support partitioned tokens (identity + position + seq/event index).
src/​Orleans.Streaming/​Generator/​GeneratorPooledCache.cs Adds internal ctor for purge predicate injection and clears current buffer when cache becomes empty.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​RecoverableStreamStartPosition.cs Adds a value type describing checkpoint/start-from-now initialization for recoverable sources.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​QueueAdapterReceiverRegistry.cs Adds a receiver/cache registry to ensure one coordinator per queue shared by receiver + cache factories.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​IRecoverableStreamSource.cs Adds recoverable partition source abstraction for ordered reads and lifecycle.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​IRecoverableStreamReplaySource.cs Adds replay source factory + replay reader contracts + replay read result type.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​IRecoverableStreamQueueCache.cs Adds cache contract used by recoverable receiver, including newest/oldest offsets and replay progress hooks.
src/​Orleans.Streaming/​Common/​RecoverableStreams/​IRecoverableStreamDataAdapter.cs Adds data-adapter contract mapping immutable records to cached messages and provider offsets.
src/​Orleans.Streaming/​Common/​RecoverableStreamOptions.cs Introduces RecoverableStreamReplayOptions (bounded readers/pending/cache/read batch size/retry delay).
src/​Orleans.Streaming/​Common/​RecoverableStreamConfigurator.cs Wires replay options into configurator extension points and logging configuration.
src/​Orleans.Streaming/​Common/​PooledCache/​IEvictionStrategy.cs Adds OnPurgeCompleted hook for post-owner purge accounting.
src/​Orleans.Streaming/​Common/​PooledCache/​ICacheDataAdapter.cs Adds adapter-aware Compare hook for caches with external offsets.
src/​Orleans.Streaming/​Common/​PooledCache/​FixedSizeBuffer.cs Adds internal Position and ResetTo to support precise buffer state management.
src/​Orleans.Streaming/​Common/​PooledCache/​ChronologicalEvictionStrategy.cs Refactors purge completion and ensures buffers are freed when cache becomes empty.
src/​Orleans.Streaming/​Common/​PooledCache/​CachedMessageBlock.cs Clears cached message slots on remove/reset and adds adapter-aware index search overload.
src/​Orleans.Streaming/​Common/​PartitionedStreamSequenceToken.cs Adds provider/partition identity + position-aware token type with JSON support.
src/​Orleans.Streaming/​Common/​EventSequenceTokenV2.cs Preserves concrete derived token type when creating per-event tokens and clarifies compatibility semantics.
src/​Orleans.Streaming/​Common/​EventSequenceToken.cs Same as V2: preserve concrete type for CreateSequenceTokenForEvent and clarifies compatibility semantics.
src/​Orleans.Streaming/​Checkpointers/​StreamQueueCheckpointerOptions.cs Adds new options type for StreamQueueCheckpointer.
src/​Orleans.Streaming/​Checkpointers/​StreamQueueCheckpointer.cs Adds versioned, conditional-update-based checkpointer implementation with throttling and retry behavior.
src/​Orleans.Streaming/​Checkpointers/​StreamCheckpointStoreState.cs Adds value type representing (checkpoint, version) state from a checkpoint store.
src/​Orleans.Streaming/​Checkpointers/​IStreamCheckpointStore.cs Adds interface for checkpoint stores supporting conditional versioned updates.
src/​Orleans.Streaming/​Checkpointers/​GrainStreamQueueCheckpointer.cs Refactors grain-based checkpointer to use StreamQueueCheckpointer via an adapter.
src/​Azure/​Shared/​Storage/​AzureTableDataManager.cs Adds cancellation support to init/insert operations and adds conditional update helper.
src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubSequenceToken.cs Tightens equality/ordering to Event Hub token versions only; rejects generic tokens.
src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubQueueCache.cs Clears current buffer reference when purge empties the cache.
src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubCheckpointer.cs Adds cancellation-aware factory overloads for checkpointer creation.
src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubAdapterFactory.cs Uses shared receiver/cache registry instead of ad-hoc receiver dictionary.
src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​AzureTableStreamQueueCheckpointerFactory.cs Adds cancellation-aware Create overload and obsoletes non-CT overload.
src/​Azure/​Orleans.Reminders.AzureStorage/​Storage/​AzureBasedReminderTable.cs Passes lifecycle cancellation through table initialization.
src/​Azure/​Orleans.GrainDirectory.AzureStorage/​AzureTableGrainDirectory.cs Passes cancellation token through table initialization.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisSequenceToken.cs Extends Kinesis token with partition identity and ordering based on durable shard sequence.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisBatchContainer.cs Preserves event-index ordering and supports cached-record reconstruction with identity-aware tokens.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisAdapterReceiver.cs Clarifies receiver-local ordinal usage for legacy token compatibility.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisAdapterFactory.cs Switches to shared receiver/cache, marks provider rewindable, and wires replay options.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​DynamoDBStreamQueueCheckpointer.cs Migrates to StreamQueueCheckpointer + IStreamCheckpointStore semantics.
src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​DynamoDBStreamCheckpointStore.cs Migrates to versioned checkpoint store state for conditional updates.
src/​AWS/​Orleans.Streaming.Kinesis/​README.md Documents retained-history replay configuration and failure modes.
src/​AWS/​Orleans.Streaming.Kinesis/​Hosting/​SiloKinesisStreamConfigurator.cs Adds replay configuration plumbing for silos.
src/​AWS/​Orleans.Streaming.Kinesis/​Hosting/​ClusterClientKinesisStreamConfigurator.cs Adds replay configuration plumbing for clients.
src/​api/​Azure/​Orleans.Streaming.EventHubs/​Orleans.Streaming.EventHubs.cs Updates generated API surface for new/updated Event Hubs streaming APIs.
src/​api/​AWS/​Orleans.Streaming.Kinesis/​Orleans.Streaming.Kinesis.cs Updates generated API surface for new replay configuration methods.
src/​api/​AdoNet/​Orleans.Streaming.AdoNet/​Orleans.Streaming.AdoNet.cs Updates generated API surface for ADO.NET provider option/schema changes and replay configuration.
src/​AdoNet/​Shared/​Storage/​RelationalStorageExtensions.cs Adds cancellation token support to relational storage ReadAsync extension.
src/​AdoNet/​Orleans.Streaming.AdoNet/​README.md Updates provider guidance for partitioned model, retention, and replay leases (alpha schema v3).
src/​AdoNet/​Orleans.Streaming.AdoNet/​Hosting/​SiloAdoNetStreamConfigurator.cs Adds replay options to named configuration and exposes ConfigureReplay.
src/​AdoNet/​Orleans.Streaming.AdoNet/​Hosting/​ClusterClientAdoNetStreamConfigurator.cs Adds replay options to named configuration and exposes ConfigureReplay.
src/​AdoNet/​Orleans.Streaming.AdoNet/​Extensions.cs Removes time-rounding helper extensions (replaced by AdoNetStreamTime).
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamTime.cs Adds SQL-safe interval validation and “round up to seconds” conversion.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamSequenceToken.cs Adds identity-aware ADO.NET stream token implementing partitioned token interface.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamReplayState.cs Adds internal state types for replay lease and page result handling.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamPartitionState.cs Adds internal state type for partition durable position and retained bounds.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamOptionsValidator.cs Updates validation to new partitioned options/interval constraints and replay lease rules.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamOptions.cs Replaces legacy queue/dead-letter options with partitioned retention, checkpoint, cleanup, and replay lease settings.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamMessage.cs Updates stored message schema (stream id bytes + namespace length) and exposes reconstructed StreamId.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamFailureHandler.cs Switches to logging-based failure handling while preserving shared partition records.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamDeadLetter.cs Removes dead-letter model (no longer used by partitioned provider).
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamConfirmationAck.cs Removes confirmation ack model (no longer used).
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamConfirmation.cs Removes confirmation model (no longer used).
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamCleanupResult.cs Adds internal model describing cleanup outcomes including hard-retention deletions.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamCheckpointUpdate.cs Adds internal model describing epoch-fenced checkpoint update results.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetQueueAdapterFactory.cs Makes factory also act as queue cache provider and wires replay options into adapter creation.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetQueueAdapter.cs Makes adapter rewindable, switches enqueue to partition append, and uses shared receiver/cache registry.
src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetBatchContainer.cs Updates event-index token assignment to preserve per-record event index across type filtering.
docs/​site/​src/​content/​docs/​streaming/​stream-providers.md Updates provider matrix and ADO.NET/Kinesis rewindability guidance.
docs/​site/​src/​content/​docs/​streaming/​kinesis-streaming.md Documents retained-history replay behavior and configuration for Kinesis.
docs/​site/​src/​content/​docs/​streaming/​delivery-semantics.md Updates delivery/replay semantics documentation to include retained-history replay and handoff behavior.
docs/​site/​src/​content/​docs/​streaming/​data-adapters.md Clarifies token construction guidance relative to stream partitions.
docs/​site/​src/​content/​docs/​streaming/​custom-queue-adapter.md Updates guidance for implementing retained-history adapters and async cursors.
docs/​site/​src/​content/​docs/​implementation/​streams-implementation/​index.md Updates internal streaming implementation docs for safe contiguous partition progress semantics.
docs/​site/​src/​content/​docs/​host/​monitoring/​signals.md Tightens wording around dashboard vs durable telemetry.

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

Copilot AI review requested due to automatic review settings September 4, 2026 17:31

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 change set introduces new streaming replay APIs and touches multiple providers and persistence/checkpoint paths, requiring careful end-to-end validation beyond what automated review can confidently approve.

Review tier: Lite
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​Orleans.Streaming/​JsonConverters/​EventSequenceTokenJsonConverter.cs — ReadPartitionedToken rejects deserializing discriminator=3 tokens when the requested type is…
Issues resolved since last review (3)
Severity Finding
High severity src/​Orleans.Streaming/​Common/​PartitionedStreamSequenceToken.cs — The [Id] values on PartitionedStreamSequenceToken overlap with the base EventSequenceTokenV2 field… View resolved comment
High severity src/​AdoNet/​Orleans.Streaming.AdoNet/​AdoNetStreamSequenceToken.cs — AdoNetStreamSequenceToken uses [Id(0..2)] for its own members even though it inherits… View resolved comment
High severity src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisSequenceToken.cs — KinesisSequenceToken declares additional Orleans-serialized members using [Id(0..2)], which… View resolved comment

@ReubenBond

Copy link
Copy Markdown
Member Author

Current CI at head \60cd72566f\ has a PR-specific Redis streaming regression in both net8.0 and net10.0 (run 33901060370). Five \RedisStreamingResumeTests\ cases consistently time out waiting for expected delivery: \ResumeAfterInactivity, \ResumeAfterDeactivationActiveStream, \ResumeAfterDeactivation, \ResumeAfterSlowSubscriber, and \ResumeAfterInactivityNotInCache. The cross-target repetition indicates the retained-history changes need correction rather than a blind retry. The active PR session is addressing this together with the new base-typed partition-token round-trip review finding.

Copilot AI review requested due to automatic review settings September 4, 2026 18:12

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

It introduces broad streaming API/behavior changes across multiple providers and requires full end-to-end validation beyond the issues noted in code review comments.

Review tier: Lite
Findings: None

Issues resolved since last review (1)
Severity Finding
High severity src/​Orleans.Streaming/​JsonConverters/​EventSequenceTokenJsonConverter.cs — ReadPartitionedToken rejects deserializing discriminator=3 tokens when the requested type is… View resolved comment
Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptions.cs:60

  • The XML remarks state that fractional-second values are rounded up, but the validator enforces a minimum of 1 second (via AdoNetStreamTime.IsValidSqlInterval and AdoNetStreamOptionsValidator). Either the validator should allow sub-second values (rounding them up), or the docs should explicitly state the 1-second minimum to avoid misleading configuration guidance.

Copilot AI review requested due to automatic review settings September 4, 2026 18:43

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

Newly created Kinesis live-delivery tokens still omit stream/shard identity (null), undermining the intended token-identity validation for retained-history replay and risking cross-partition token misuse.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisAdapterReceiver.cs — KinesisSequenceToken now supports embedding stream/shard identity, but live reads still construct…
Suppressed comments (4)

Previously missed (2) — in code that hasn't changed since the last review.

src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamSequenceToken.cs:53

  • Provider identity/position are recomputed via string allocations (interpolated GetProviderIdentity + SequenceNumber.ToString(...)) on every Equals call. Since tokens are compared and hashed frequently, consider caching these computed strings in non-serialized fields and reusing them.

This issue also appears in the following locations of the same file:

  • line 65
  • line 81
    src/Orleans.Streaming/Common/PartitionedStreamSequenceToken.cs:147
  • ComparePositions uses left[leftStart..]/right[rightStart..] which allocates new substrings on every comparison. Since these tokens are compared frequently (ordering, equality, cache positioning), this can create avoidable allocations. Prefer a span-based numeric check (similar to GetPositionHashCode).

src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamSequenceToken.cs:85

  • GetHashCode also recomputes provider identity and position strings, which can allocate and add overhead when tokens are used as dictionary/set keys. If ProviderIdentity/Position are cached, use them here too to keep hashing allocation-free.
    src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamSequenceToken.cs:69
  • CompareTo currently allocates via GetProviderIdentity(...) and SequenceNumber.ToString(...) each time it runs. With cached ProviderIdentity/Position strings, this method can avoid those per-compare allocations.

Copilot AI review requested due to automatic review settings September 4, 2026 20:09
@ReubenBond
ReubenBond force-pushed the rb-feat-streaming-retained-history-replay branch from 3dbc0a2 to dadea50 Compare September 4, 2026 20: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

🔵 Needs a closer look

It introduces broad runtime and public-API changes across multiple streaming providers and core caching/checkpoint semantics, requiring careful end-to-end validation beyond this automated review.

Review tier: Lite
Findings: None

Issues resolved since last review (1)
Severity Finding
High severity src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisAdapterReceiver.cs — KinesisSequenceToken now supports embedding stream/shard identity, but live reads still construct… View resolved comment

Copilot AI review requested due to automatic review settings September 5, 2026 10:21
@ReubenBond
ReubenBond force-pushed the rb-feat-streaming-retained-history-replay branch from dadea50 to 56a2ad3 Compare September 5, 2026 10:21

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

It introduces broad public API and behavioral changes across multiple streaming providers (replay, checkpointing, token semantics, cache/eviction), which warrants careful end-to-end validation and human review.

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubCheckpointer.cs — The legacy Create(partition) overload is obsolete on IStreamQueueCheckpointerFactory, but this…

Copilot AI review requested due to automatic review settings September 5, 2026 10:31
@ReubenBond
ReubenBond marked this pull request as ready for review September 5, 2026 10:31

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 changes span core streaming abstractions, provider implementations, serialization/token semantics, and checkpointing, which is broad enough that it warrants final human review despite test and documentation updates.

Review tier: Lite
Findings: None

Issues resolved since last review (2)
Severity Finding
Low severity src/​Azure/​Orleans.Streaming.EventHubs/​Providers/​Streams/​EventHub/​EventHubCheckpointer.cs — The legacy Create(partition) overload is obsolete on IStreamQueueCheckpointerFactory, but this… View resolved comment
High severity src/​AWS/​Orleans.Streaming.Kinesis/​Streams/​KinesisSequenceToken.cs — KinesisSequenceToken declares additional Orleans-serialized members using [Id(0..2)], which… View resolved comment
Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/AWS/Orleans.Streaming.Kinesis/Streams/KinesisAdapterFactory.cs:37

  • SemaphoreSlim _initializationSemaphore is introduced to guard one-time adapter initialization but is never disposed, even though this type implements IDisposable. This can leak a wait handle for the lifetime of the process (especially if multiple factories are created in tests or dynamically).

Copilot AI review requested due to automatic review settings September 5, 2026 10:38

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 change set spans core streaming APIs, multiple providers, serialization/token contracts, checkpointing, and cache eviction behavior, requiring careful end-to-end validation beyond an automated review.

Review tier: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 5, 2026 10:49
Preserve legacy Kinesis token serialization, reject invalid ADO.NET replay positions, integrate cache-miss recovery, retain future replay starts, and align provider documentation with implemented replay ranges.
Port the isolated runtime correction and four regression cases from foundation commit 79e7864af6b44b847540c4bd78ca209e5faa5622. Exercise this branch's explicit record-count capacity while preserving inclusive delivery, retry, quiet-partition scan, and checkpoint barriers.
Regenerate all four replay-related package API surfaces after rebasing onto current main. Capture the Azure Table adapter cancellation overloads integrated with the reusable checkpoint core.

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 Unicode stream-namespace byte-offset issues remain unresolved, and the change set is high risk.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity

Open (4)

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.

Make persistent streams rewindable

3 participants