Repository navigation
fix(domain): in-memory key maps keep the entry another fiber made first - #3779
Open
StvyaSharma wants to merge 1 commit into
Open
StvyaSharma wants to merge 1 commit into
StvyaSharma wants to merge 1 commit into
Conversation
A view key's get, a stream key's get and an aggregate's version ref were made after a check and a yield, then set unconditionally. A read (which does not take the view's lock) touching a key for the first time while the view applied its first event replaced the entry the event was applied to: the event was lost and a read atLeast its receipt timed out.
Contributor
|
Install the packages built from this commit: alchemypnpm install https://pkg.alchemy.run/alchemy/pr:3779:ea4f061@alchemy.run (15)pnpm install https://pkg.alchemy.run/@alchemy.run/acme/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/hetzner/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/railway/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/fly/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/gcp/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/aws/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/domain/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/kubernetes/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/docker/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/redis/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/sql/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare-runtime/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/node-utils/pr:3779:ea4f061Transitive Dependencies (14)pnpm install https://pkg.alchemy.run/@distilled.cloud/aws/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/acme/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/core/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/s3/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/hetzner/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/railway/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/fly-io/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/aws4signer/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/cloudflare/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/iceberg/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/gcp/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/effect-cluster/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@alchemy.run/rivet/pr:3779:ea4f061pnpm install https://pkg.alchemy.run/@distilled.cloud/rivet/pr:3779:ea4f061Published |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With
InMemory, a view no longer loses an event when a read touches its key for the first time while the view applies that key's first event.A view key's
getchecks thekeysmap, makes the key'sSubscriptionRefs, then sets the key. Making the refs can yield, and the view's reads callgetwithout the view's lock, whileapplyholds it. When both miss the same key, the one that sets last replaces the other's entry. If the read sets last, the event lands in an orphaned entry.Each key is now set only if no other fiber set it first:
The stream key's
getand the aggregate'sversionOfused the same pattern and get the same fix.The yield comes from Effect's scheduler after
MaxOpsBeforeYieldops, so at default settings it is rare. The new "Domain InMemory: view keys" test setsScheduler.MaxOpsBeforeYieldto 1 so it happens on every run.