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
{{ message }}
Repository navigation
Add durable entity support to the in-memory test backend - #188
Part of #180. Stacked on #185 (rewind), which is stacked on #183 (in-memory test host). Resolves#180
Summary
The durabletasktest in-memory backend now supports durable entities. Before this change, entity RPCs returned Unimplemented and orchestrations that emitted entity actions failed with NotSupported.
What's supported
Entity work items: V2 EntityRequest dispatch over GetWorkItems, with optional entity-name filters, plus CompleteEntityTask and AbandonTaskEntityWorkItem. If a work-item stream ends, its leased entity batches are requeued.
Batch results:
Successful batches persist entity state, route call results back to callers, and apply entity actions: signals to other entities and starts of new orchestrations.
A failed batch fails its pending calls with EntityOperationFailed and leaves state unchanged.
Orchestration actions:
Calls, signals, and locks produce EntityOperationCalled/Signaled/Completed/Failed, EntityLockRequested/Granted, and EntityUnlockSent events.
The backend sets EntityParameters with a zero reorder window so the orchestrator enables entity APIs.
Critical sections: These follow DTS and .NET semantics.
A lock request moves through the sorted lock set one entity at a time.
While an entity is locked, it processes only messages from the lock owner, plus that owner's unlock.
Other signals and calls wait until the lock is released.
Client RPCs:
SignalEntity, including a scheduled time, which uses a real-time timer.
GetEntity.
QueryEntities, with an ID prefix, a time range, an option to include transient entities, page size, and continuation.
CleanEntityStorage, which removes empty entities and releases locks whose owning orchestration is missing or terminal.
Error codes: These match client/grpc_errors.go and internal/grpcerrors.
InvalidArgument: bad entity IDs, empty operation names, or bad continuation tokens.
NotFound: unknown completion tokens.
Rewind: Rewinding a failed orchestration keeps the entity call results already in its history.
Docs and tests
The durabletasktest package doc, the README section "Testing orchestrations", and the CHANGELOG entry no longer list entities as unsupported.
The entity case in TestUnsupportedFeatures is replaced by end-to-end entity tests in durabletasktest/entity_test.go:
client signals, including scheduled signals
orchestration calls and signals
operation failure
entity-to-entity signals and orchestration starts
critical sections
queries
storage cleanup
rewind with entity calls
Unit tests in internal/inmemory/entity_test.go cover lock gating, orphaned-lock cleanup, and requeueing entity work items when a stream is released.
The reason will be displayed to describe this comment to others. Learn more.
Reusing the normal client and worker makes in-memory entity tests more useful. I would hold this until two cases are fixed: a terminated orchestration can leave later entities in a lock set locked indefinitely, and a backlog of individually valid signals can produce a work item that stops the host's only worker.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical unresolved issues allow oversized batches to block shared worker intake, discard entity results after rewind, and retain stale locks after orchestration replacement, while entity queries also mishandle the exclusive timestamp upper bound.
Adds durable entity support to durabletasktest, extending the in-process test host to exercise entities through the real client, worker, and executor without an emulator.
Changes:
Adds entity dispatch, state persistence, result routing, scheduled signals, queries, and storage cleanup.
Integrates orchestration entity actions and critical-section locks.
Adds entity tests, including rewind preservation, and updates testing documentation.
File
Description
README.md
Documents entity testing and removes the unsupported-entity limitation.
internal/inmemory/work.go
Integrates entity dispatch, stream-release requeueing, and orchestration actions.
internal/inmemory/server.go
Adds entity queues, leases, lock tracking, and timer management.
internal/inmemory/entity.go
Implements entity batching, completion, locking, and client RPCs.
internal/inmemory/entity_test.go
Tests lock handling, cleanup, batch sizing, and lease requeueing.
durabletasktest/host.go
Updates package documentation to describe entity support.
durabletasktest/host_test.go
Removes the test asserting entities are unsupported.
durabletasktest/entity_test.go
Adds end-to-end coverage for entity operations, locks, queries, cleanup, and rewind.
CHANGELOG.md
Records entity support in the test host’s feature list.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Outstanding entity-call responses are discarded after rewind, and locks can survive replacement of their owning execution, leaving orchestrations and callers blocked indefinitely.
An empty entity-filter list means unrestricted intake, not reject-all: workItemFiltersFromRegistry produces it for an entity registered as "*", and workItemFiltersToProto uses a separate sentinel for reject-all. With a wildcard registration the filters object is still non-nil, so this check rejects every entity and signals/calls never execute. Treat an empty entity list as unrestricted, matching client/grpc_worker_processor.go:820-830.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical entity-handling defects discard results needed for replay and block entity dispatch when only other work-item filters are configured, causing calls to wait indefinitely.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Empty entity filters incorrectly block all entity work, and entity results lost during caller failure can leave rewound orchestrations waiting indefinitely.
Drop lock acquisitions whose requesting execution has ended so a terminated
waiter can't lock entities after its unlocks have passed them. Select entity
operations in one pass and stop before a work item exceeds the worker's gRPC
receive limit, leaving the remaining operations queued.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Enforce the work item size limit for the first operation in a batch too.
Operations that can't fit even alone are removed so they can't stall the
entity; calls fail with EntityOperationTooLarge and signals are dropped.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Locks record the owning execution, so cleanup releases locks left by a
replaced instance and only that execution's calls run under them. Rewind
rebinds outstanding calls, lock requests, and locks to the renewed
execution. Entity queries treat LastModifiedTo as exclusive.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Malformed request IDs are accepted, causing workers to repeatedly requeue undispatchable batches and block subsequent operations on the affected entity.
Realign the NewServer field initializers that the entity fields left unformatted.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A failed signal-only batch can leave its entity with nothing to dispatch, so pumping the entity doesn't notify waiting streams. Notify them as the success path does so another queued entity can use the freed concurrency slot without waiting for the next event or health ping.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
QueryEntities continuation tokens were offsets into a result set rebuilt for each page, so entities added or removed between pages caused later pages to skip or repeat entities. Encode the last returned instance ID instead and resume at greater IDs, as instance queries do. Malformed tokens still return InvalidArgument.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Workers refuse entity work items whose signal or call request IDs aren't UUIDs, so an accepted malformed ID made the worker abandon the batch repeatedly and blocked the entity. SignalEntity now returns InvalidArgument for a supplied request ID that isn't a UUID and still generates one when it's omitted. Orchestration entity messages with a malformed request ID or entity instance ID now fail the orchestration instead of being delivered undispatchable or dropped.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
An oversized combined batch result can exceed the receive limit and trigger indefinite re-execution while callers wait, requiring bounded failure handling and regression coverage.
The reason will be displayed to describe this comment to others. Learn more.
The terminated lock acquisition and oversized incoming batch cases are fixed. I would hold this until oversized completions stop re-running the same operations and the host reports signals it cannot dispatch instead of acknowledging and silently dropping them.
SignalEntity now returns InvalidArgument when a signal's input and the
entity's current state can't fit together in an entity work item, using
the same sizing as dispatch. Signals rejected at dispatch time, such as
scheduled signals or signals from orchestrations and entities, are no
longer dropped silently: the in-memory service logs a warning with the
entity ID, operation, and sizes through the durabletasktest host logger.
Document the combined state and input limit.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The worker abandons an entity completion that the service rejects for
size, so the service rebuilt and re-ran the same batch indefinitely.
CompleteEntityTask now checks the batch result size itself: a result over
4 MiB isn't applied, the entity's state is unchanged, each call in the
batch fails with the non-retriable error type EntityResultTooLarge, and
each signal is logged as dropped. The operations run once.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A host created with durabletasktest.New now also reports each entity
signal that the in-memory service drops with testing.TB.Log, so drops
show up when a test fails or runs with -v even if the test doesn't set
WithLogger.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Entity query pages are not bounded by serialized response size, so valid large states can exceed the client’s 64 MiB receive limit and cause ResourceExhausted failures.
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.
Part of #180. Stacked on #185 (rewind), which is stacked on #183 (in-memory test host). Resolves #180
Summary
The
durabletasktestin-memory backend now supports durable entities. Before this change, entity RPCs returnedUnimplementedand orchestrations that emitted entity actions failed withNotSupported.What's supported
EntityRequestdispatch overGetWorkItems, with optional entity-name filters, plusCompleteEntityTaskandAbandonTaskEntityWorkItem. If a work-item stream ends, its leased entity batches are requeued.EntityOperationFailedand leaves state unchanged.EntityOperationCalled/Signaled/Completed/Failed,EntityLockRequested/Granted, andEntityUnlockSentevents.EntityParameterswith a zero reorder window so the orchestrator enables entity APIs.SignalEntity, including a scheduled time, which uses a real-time timer.GetEntity.QueryEntities, with an ID prefix, a time range, an option to include transient entities, page size, and continuation.CleanEntityStorage, which removes empty entities and releases locks whose owning orchestration is missing or terminal.client/grpc_errors.goandinternal/grpcerrors.InvalidArgument: bad entity IDs, empty operation names, or bad continuation tokens.NotFound: unknown completion tokens.Docs and tests
durabletasktestpackage doc, the README section "Testing orchestrations", and the CHANGELOG entry no longer list entities as unsupported.TestUnsupportedFeaturesis replaced by end-to-end entity tests indurabletasktest/entity_test.go:internal/inmemory/entity_test.gocover lock gating, orphaned-lock cleanup, and requeueing entity work items when a stream is released.