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
Membership provider authors need reusable behavioral checks for atomic writes, coherent canonical reads, and cleanup across independent handles and isolated cluster scopes, while keeping periodic liveness updates free of membership contention.
Solution
Add Microsoft.Orleans.Clustering.TestKit, a framework-neutral package with 27 independently invocable scenarios and actual Microsoft.Accordant-generated operation histories. The package uses Orleans Core and Accordant; its pure self-tests use independent oracles and deliberate contract-violating implementations.
Canonical mutations atomically validate TableVersion.VersionEtag, update the intended existing row, and advance the table version exactly once. Stale table snapshots, duplicate inserts, missing-row updates, and competing writes have atomic outcomes. Row ETags are opaque provider-defined metadata: a provider can independently validate a canonical row token, or ignore the supplied row ETag when table-version CAS protects the existing-row update. Positive oracles cover both stronger row checks and physical row metadata with version-only CAS.
Equal-version histories preserve every non-Dead row, retained canonical field, and table version/ETag while allowing Dead-only pruning. A newer view can establish a missing previously-live identity's terminal death. Cleanup accepts an unchanged version or valid atomic +1 batches. Allowed cleanup outcomes are bounded and their canonical row effects validated before entering the model. Row metadata can vary across reads and cleanup without defining a new canonical view.
Each owning silo publishes its own IAmAliveTime through one blind liveness-column write. Heartbeats preserve canonical membership fields and the table version/ETag; physical row ETags may change. Direct and generated cases capture row/table inputs, perform an owner heartbeat, and commit a status or vote update using those original inputs with exactly one +1 commit. Provider-native instrumentation verifies zero prerequisite reads, zero compare-and-swap operations, and exactly one periodic liveness write.
Raw IAmAliveTime reads can lag or regress, and full-row membership writes can overwrite a heartbeat with an earlier value. Canonical comparisons exclude raw liveness and row metadata. The model keeps generated owner timestamps independently from provider observations; private oracle variants exercise lag, full-row overwrite, and cheap preservation without learning observed canonical state. Runtime snapshot observed-maximum behavior remains covered by #11296.
Fixtures own independent handles, isolated scopes, explicit initialization, and bounded teardown waits. A mandatory read-only native deletion probe checks the original populated backing scope, then verifies actual deletion or invalidation before owner disposal. Generated deletion ends its history. Admitted factory, native initialization, terminal deletion/probe, and cleanup operations retain their owners through actual completion, independently of canceled caller waits. A shared cleanup task preserves late failures; teardown failure stops further generated cases and replay. Concurrent initialization shares the same three handles, and ownership registration is atomic with terminal disposal.
The self-test assembly participates in Suite=BVT / Provider=None. Pagination-sized concurrency setup preserves N actual inserts and per-commit +1 checks while using N+1 point reads plus two final full views against independently constructed canonical rows. Include the generated API surface, package metadata, and focused usage documentation.
Scope and rationale
This is an independent PR against main, carved from the recorded membership-conformance snapshot and aligned with #11296. It contains no commits from #11307. Production providers, runtime/host integrations, and stronger conformance activation in existing provider suites remain separate work. Receipt-based ReadRow retirement is a separate follow-up.
The first commit, bede893d290a9035f196f4c3ed58213d102efc6c, corrects only the legacy shared cleanup test's baseline data and assertions: old Active/Dead plus fresh Active, retaining exactly three Active rows and removing Dead rows. The separate reusable commit 4f316eaf52681b3a313571ad093cf398b9118690 checks the complete table version after rejected updates instead of requiring row-metadata equality. Both preserve the base class API and can be reused independently of the kit.
Adds a framework-neutral membership provider conformance kit with direct scenarios, Accordant-generated histories, fixtures, test doubles, API metadata, and documentation.
Changes:
Added membership table runners, snapshots, models, fixtures, and diagnostics.
Added comprehensive idealized and faulty-provider self-tests.
Updated legacy cleanup coverage, packaging, solution, and provider documentation.
The post-factory _disposed check is not atomic with adding the handle to _handles and _clusters. DisposeAsync can set _disposed and finish iterating those collections after this check but before lines 130-132, leaving a successfully created handle unregistered and never disposed. Protect the check-and-register sequence with the same lifecycle synchronization used by disposal.
The newest successful coverage run tested 986e5c7, not current main dcf2925.
Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.
The comparison remains report-only while normal line and branch variance is calibrated.
Addressed the body-only finding Synchronize handle registration with fixture disposal in review 5246252042 with commit 5beec78.
Handle acceptance and registration now use the same lifecycle lock as marking the fixture disposed and snapshotting its owned handles/live scopes. Provider factories and disposal callbacks run outside the lock. A factory completing after disposal or terminal history retirement disposes its returned owner before reporting the lifetime error; cleanup failures still propagate. Teardown iterates stable ownership snapshots.
Added gated regressions for factory completion during/after disposal, registration before disposal, terminal retirement during a pending factory, and late-owner disposal failure. They assert exact disposal counts and zero calls through invalidated providers without sleeps. Fixture and native-deletion regression classes pass on Release net8.0 and net10.0 (24 tests per target, zero failures/skips); both projects pass whitespace verification.
Audited the other review bodies and inline threads: the only other actionable finding was provider cancellation being mislabeled as a runner timeout, already fixed in 247e2d9 with its inline thread resolved. The PR remains draft for human review; CI is running on the new head.
Two callers can both observe _initialized == false and run the three factory calls concurrently. They then overwrite First/Second/OtherCluster; depending on timing, some of the six acquired handles are never initialized, while the fixture reports successful initialization and retains extra owners. Serialize initialization (for example, cache and await one shared initialization task) so concurrent callers share the same three handles.
Addressed the foreign-read mutant owner finding from review 5251235057 in 16918a7. The temporary cross-cluster provider is now owned by an await using test handle and disposed after the read, including failure paths. The read runs outside the backend lock instead of blocking on an async result inside it.
The deliberate cross-cluster violation is still detected, and its test now asserts exactly four created owners and four disposed owners. All 30 direct-guarantee mutant cases pass on both Release net8.0 and net10.0, with zero skips; formatting verification passes.
The previously resolved accepted-handle lifetime fix remains in place for live, retired, and disposed branches. Distinct wrappers retain explicit per-handle ownership semantics; the fixture rejects duplicate provider instances rather than inferring ownership of opaque resources.
Regarding the overview in review 5251343786: the exact already-accepted handle case is guarded before live/retired/disposed rejection and covered by the gated CreateAdditionalHandle_LateAcceptedHandleWaitsForOtherAdmittedOperations cases.
A distinct MembershipTableTestHandle has an explicitly supplied resource owner/disposer. The fixture cannot infer whether two arbitrary delegates share a resource merely because their tables are reference-equal. A factory sharing a native owner must correctly lease or reference-count that owner across its handles. This follows the constructor contract: the supplied disposer owns the resources for that handle. Duplicate provider instances are rejected as fixture errors. Newly acquired rejected wrappers still have their own declared resources cleaned up, while accepted handles remain under the fixture's shared teardown task.
Concrete evidence in MembershipTableTestFixtureTests:
CreateAdditionalHandle_LateAcceptedHandleWaitsForOtherAdmittedOperations covers both history retirement and concurrent disposal, retaining the accepted owner while native verification is paused.
CreateAdditionalHandle_DuplicateTableDisposesOnlyRejectedWrapperBeforeTeardown proves a distinct rejected wrapper is disposed exactly once, while the accepted owner remains untouched; returning the exact accepted handle again also preserves it.
CreateAdditionalHandle_RejectedWrapperCleanupFailurePreservesDuplicateFailure proves rejected-owner cleanup errors retain the original conformance failure and remain observable through shared teardown.
Initialize_SingletonFactory_IsRejectedAndAcquiredOwnerDisposedOnce covers repeated identical handles during initialization.
The no-change disposition concerns only speculative sharing behind distinct opaque disposer delegates. No additional ownership protocol, API change, or linear-setup change is warranted. Receipt-based ReadRow retirement remains a separate follow-up.
CompleteDisposalAsync is invoked synchronously here, and its first delete/disposer call is executed inline until it returns an incomplete task. A legacy IMembershipTable implementation can legally perform blocking work before returning its tokenless Task, so DisposeAsync may block indefinitely before it reaches completion.WaitAsync(waitTimeout), defeating the documented 30-second caller bound. Start the completion operation asynchronously (or otherwise isolate synchronous provider dispatch) before waiting.
The pending-operation set only contains fixture-internal factory, initialization, deletion, and probe tasks, but the runner invokes ReadAllAsync/ReadRowAsync/InsertRowAsync/UpdateRowAsync/UpdateIAmAliveAsync/CleanupDefunctSiloEntriesAsync directly with a cancellable token. For a tokenless provider, IMembershipTable's default async adapters cancel the caller's wait while the underlying operation continues; a scenario timeout or cancellation can therefore reach this disposal snapshot with provider work still using the owner, after which lines 443-453 delete and dispose it. Track all provider invocations with the fixture's lifetime coordination (including direct foreign-deletion calls), or defer owner disposal until those operations complete.
This issue also appears on line 418 of the same file.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟢 Approval recommended
The conformance kit, lifecycle and concurrency handling, self-tests, packaging, generated API, and documentation were reviewed with no unresolved correctness issues.
Synchronous cleanup dispatch: confirmed and fixed in f28da90. With no incomplete admitted tasks, inline dispatch could execute a synchronously blocking delete/disposer before the bounded caller wait began. Cleanup now starts on a worker task while the same shared completion task retains ownership and late failures. The gated synchronous-delete and synchronous-disposer regressions failed before the fix and pass afterward; fixture/deletion/cleanup classes pass 43 tests per framework on Release net8.0 and net10.0, zero skips.
Ordinary membership calls: the approved scope remains fixture-owned factory, initialization, terminal deletion/probe, and cleanup work. Ordinary calls retain their scenario cancellation token and the provider's actual cancellation behavior. Tracking a returned canceled compatibility-adapter task cannot expose its hidden native task, while universally passing None would change the behavior under test. The kit does not promise quiescence of all hidden ordinary work after cancellation. Handle owners release declared resources according to the actual SDK close, abort, or drain contract, with errors visible; some SDKs legitimately fault in-flight I/O. No blanket draining guarantee, provider wrapper, or all-call ownership layer is being introduced. A concrete supported owner violating its real SDK resource contract should be investigated at that boundary.
The README now states these boundaries explicitly. Public APIs, blind heartbeat behavior, table-version CAS semantics, and linear pagination setup are unchanged.
Current-head review 5252300970 reports no findings and repeats the distinct-wrapper ownership overview. The disposition remains the documented one in the ownership response: exact already-accepted handle identities are retained through pending work, with both disposed/retired gated regressions; each distinct rejected handle owns its declared resources, and factories must correctly lease/reference-count any shared opaque native owner. Table reference equality cannot establish arbitrary delegate ownership. No additional ownership protocol or all-ordinary-call tracking layer is introduced.
The current table-CAS contract and native single-attempt guidance are independent of that ownership boundary. Row ETags can vary as metadata; canonical state and the table version/ETag remain protected, and original pre-heartbeat row/table inputs must still permit one canonical update.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Membership provider authors need reusable behavioral checks for atomic writes, coherent canonical reads, and cleanup across independent handles and isolated cluster scopes, while keeping periodic liveness updates free of membership contention.
Solution
Add
Microsoft.Orleans.Clustering.TestKit, a framework-neutral package with 27 independently invocable scenarios and actual Microsoft.Accordant-generated operation histories. The package uses Orleans Core and Accordant; its pure self-tests use independent oracles and deliberate contract-violating implementations.Canonical mutations atomically validate
TableVersion.VersionEtag, update the intended existing row, and advance the table version exactly once. Stale table snapshots, duplicate inserts, missing-row updates, and competing writes have atomic outcomes. Row ETags are opaque provider-defined metadata: a provider can independently validate a canonical row token, or ignore the supplied row ETag when table-version CAS protects the existing-row update. Positive oracles cover both stronger row checks and physical row metadata with version-only CAS.Equal-version histories preserve every non-Dead row, retained canonical field, and table version/ETag while allowing Dead-only pruning. A newer view can establish a missing previously-live identity's terminal death. Cleanup accepts an unchanged version or valid atomic +1 batches. Allowed cleanup outcomes are bounded and their canonical row effects validated before entering the model. Row metadata can vary across reads and cleanup without defining a new canonical view.
Each owning silo publishes its own
IAmAliveTimethrough one blind liveness-column write. Heartbeats preserve canonical membership fields and the table version/ETag; physical row ETags may change. Direct and generated cases capture row/table inputs, perform an owner heartbeat, and commit a status or vote update using those original inputs with exactly one +1 commit. Provider-native instrumentation verifies zero prerequisite reads, zero compare-and-swap operations, and exactly one periodic liveness write.Raw
IAmAliveTimereads can lag or regress, and full-row membership writes can overwrite a heartbeat with an earlier value. Canonical comparisons exclude raw liveness and row metadata. The model keeps generated owner timestamps independently from provider observations; private oracle variants exercise lag, full-row overwrite, and cheap preservation without learning observed canonical state. Runtime snapshot observed-maximum behavior remains covered by #11296.Fixtures own independent handles, isolated scopes, explicit initialization, and bounded teardown waits. A mandatory read-only native deletion probe checks the original populated backing scope, then verifies actual deletion or invalidation before owner disposal. Generated deletion ends its history. Admitted factory, native initialization, terminal deletion/probe, and cleanup operations retain their owners through actual completion, independently of canceled caller waits. A shared cleanup task preserves late failures; teardown failure stops further generated cases and replay. Concurrent initialization shares the same three handles, and ownership registration is atomic with terminal disposal.
The self-test assembly participates in
Suite=BVT/Provider=None. Pagination-sized concurrency setup preserves N actual inserts and per-commit +1 checks while using N+1 point reads plus two final full views against independently constructed canonical rows. Include the generated API surface, package metadata, and focused usage documentation.Scope and rationale
This is an independent PR against main, carved from the recorded membership-conformance snapshot and aligned with #11296. It contains no commits from #11307. Production providers, runtime/host integrations, and stronger conformance activation in existing provider suites remain separate work. Receipt-based ReadRow retirement is a separate follow-up.
The first commit,
bede893d290a9035f196f4c3ed58213d102efc6c, corrects only the legacy shared cleanup test's baseline data and assertions: old Active/Dead plus fresh Active, retaining exactly three Active rows and removing Dead rows. The separate reusable commit4f316eaf52681b3a313571ad093cf398b9118690checks the complete table version after rejected updates instead of requiring row-metadata equality. Both preserve the base class API and can be reused independently of the kit.Microsoft Reviewers: Open in CodeFlow