Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Differences In Ancestor Values When Joining Fiber Refs #8334

Merged
merged 4 commits into from Sep 15, 2023

Conversation

adamgfraser
Copy link
Contributor

This addresses a somewhat degenerate situation where a child fiber obtains a reference to its own parent and inherits FiberRef values from its parent.

Normally, our logic when inheriting FiberRef values is to identify the common ancestor between the "joining" and "joined" fibers and compute the difference between the joined fiber's record of the ancestor value and its current value, reasoning that this represents all the changes that the joined fiber has made that should then be applied to the joining fiber.

This works in all cases but one, which is where the joined fiber is actually the parent of the joining fiber and thus the common ancestor is the joined fiber. Since we only track the current value of a FiberRef for each fiber, if the parent made a change to its FiberRef value after forking the child and then the child inherits from the parent, the child will not pick up this change.

We can instead handle this case by reasoning that if the joined fiber is the common ancestor, that is if we are inheriting from our parent, then we are inheriting from the parent after the time it forked us and thus any differences between its current FiberRef value and the value we have from when we were forked were made by the parent subsequently and thus are ones that we should apply to ourselves.

@jdegoes
Copy link
Member

jdegoes commented Aug 20, 2023

@adamgfraser Seems reasonable to me. Good to merge after conflicts resolved!

@adamgfraser adamgfraser changed the title Handle Inheriting Fiber Refs When Child Joins Parent Handle Differences In Ancestor Values When Joining Fiber Refs Aug 21, 2023
@jdegoes jdegoes merged commit 754c27e into zio:series/2.x Sep 15, 2023
22 checks passed
@adamgfraser adamgfraser deleted the fiberref branch September 19, 2023 21:57
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.

None yet

3 participants