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

feat(dds): do not opaquely encode handles in ops #19242

Merged
merged 44 commits into from
Feb 26, 2024

Conversation

connorskees
Copy link
Contributor

@connorskees connorskees commented Jan 16, 2024

Update DDSes to not opaquely encode handles as strings, but rather pass around actual objects.

AB#6382

@github-actions github-actions bot added base: main PRs targeted against main branch area: dds Issues related to distributed data structures area: dds: sharedstring area: dds: tree area: tests Tests to add, test infrastructure improvements, etc dependencies Pull requests that update a dependency file public api change Changes to a public API labels Jan 16, 2024
@@ -451,7 +457,7 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
this.reSubmit(content, localOpMetadata);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also decode handles, and then the default implementation re-encodes them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, would be excellent to get test coverage of roundtripping through these scenarios (resubmit and stashed op, maybe something with rollback)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't matter. the content is the previously submitted content, so it is already parsed. the dds then resubmits anything they want to be submitted which will subsequently get parses in the submit path again

@github-actions github-actions bot added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct and removed area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct labels Jan 30, 2024
@connorskees connorskees marked this pull request as ready for review January 30, 2024 00:17
@connorskees connorskees requested review from msfluid-bot and a team as code owners January 30, 2024 00:17
@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Jan 30, 2024
@connorskees connorskees enabled auto-merge (squash) February 24, 2024 18:33
Copy link
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final updates look good, glad to have that extra serialization cleared up in Map.

@@ -78,3 +78,16 @@ export function createSingleBlobSummary(
builder.addBlob(key, content);
return builder.getSummaryTree();
}

/**
* Binds all handles found in `value` to `bind`. Does not modify original input.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Binds all handles found in `value` to `bind`. Does not modify original input.
* Binds all IFluidHandles found in `value` to `bind`. Does not modify original input.


// Set the value locally.
const previousValue = this.setCore(key, localValue, true);

// If we are not attached, don't submit the op.
if (!this.isAttached()) {
bindHandles(localValue.value, this.serializer, this.handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here why this extra step is needed. Here and other places where this is used.

@agarwal-navin
Copy link
Contributor

@connorskees @markfields This is a risky change. We should ensure that are enough tests in place to not break anything. The scenario where a combination of new and old runtime version clients are running in parallel should be validated. We should add basic end-to-end tests where there are 2 containers - one writes and other reads and run it in full compat mode so it does the mutli-client version compat testing.

@markfields
Copy link
Member

@agarwal-navin -- I agree it is risky. Without any type validation to distinguish between encoded v. decoded handles, it's nearly impossible to tell whether all the flips/flops between those states have been addressed correctly. In fact, I know of one still in the PR that hasn't, I've logged a follow-up item.

The reason I'm not overly concerned is that functions like makeHandlesSerializable and parseHandles are idempotent - in terms of correctness, all that matters is that on the way out, the handles are encoded somewhere and on the way in it's the inverse. Seeing that we have moved coverage here to the SharedObject choke points, I feel confident that outside the DDS layer there's not going to be any behavior change here. (inside the DDS layer is another story... counting on existing test coverage here)

So as for this:

The scenario where a combination of new and old runtime version clients are running in parallel should be validated

I think we have a pretty good argument that there's no change over the wire.

That said, better safe than sorry, so the test you suggested is a good idea. I wonder if we can find an existing test that is doing this incidentally?

@connorskees what do you think?

@markfields
Copy link
Member

(Disabling auto-merge until @connorskees has a chance to respond to @agarwal-navin)

Copy link
Contributor

@Abe27342 Abe27342 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the tree changes only in latest revision. they look good. We could do further cleanup in experimental tree if we wanted to since the serializer/deserializer abstraction gets plumbed to more layers, but totally fine to push that out of this PR as is done.

@connorskees connorskees merged commit 5ea389e into microsoft:main Feb 26, 2024
31 checks passed
jzaffiro added a commit to jzaffiro/FluidFramework that referenced this pull request May 3, 2024
jzaffiro added a commit that referenced this pull request May 3, 2024
Reverts #19242 due to a bug where duplicate attach ops are sent because
of the change to encoding handles.
anthony-murphy added a commit that referenced this pull request May 9, 2024
…code (#20995)

Adds end to end tests to validate that each DDS does not send duplicate
attach ops when handles are encoded. This bug was added in #19242, and
deals with a second attach op being sent when there is a handle from one
detached DDS to another and the DDS is then attached.


[AB#7936](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/7936)

---------

Co-authored-by: Mark Fields <markfields@users.noreply.github.com>
Co-authored-by: Tony Murphy <anthony.murphy@microsoft.com>
anthony-murphy added a commit to anthony-murphy/FluidFramework-1 that referenced this pull request May 9, 2024
…code (microsoft#20995)

Adds end to end tests to validate that each DDS does not send duplicate
attach ops when handles are encoded. This bug was added in microsoft#19242, and
deals with a second attach op being sent when there is a handle from one
detached DDS to another and the DDS is then attached.


[AB#7936](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/7936)

---------

Co-authored-by: Mark Fields <markfields@users.noreply.github.com>
Co-authored-by: Tony Murphy <anthony.murphy@microsoft.com>
markfields added a commit that referenced this pull request May 20, 2024
Fixes #8016. We need to port this back to RC3 and RC4 once merged to
main.

For anyone implementing their own DDS, when they pick up an FF release
with #19242 in it, they will likely be in a position where handles are
going through `parseHandles` or `serializer.decode` twice.

We assumed this was idempotent but found that it is not, with two
different codepaths needing to be fixed.

Note that `parseHandles` may return the same object unmodified now,
wherease before it would always clone (via `JSON.stringify` roundtrip)

---------

Co-authored-by: Alex Villarreal <716334+alexvy86@users.noreply.github.com>
markfields added a commit to markfields/FluidFramework that referenced this pull request May 20, 2024
Fixes microsoft#8016. We need to port this back to RC3 and RC4 once merged to
main.

For anyone implementing their own DDS, when they pick up an FF release
with microsoft#19242 in it, they will likely be in a position where handles are
going through `parseHandles` or `serializer.decode` twice.

We assumed this was idempotent but found that it is not, with two
different codepaths needing to be fixed.

Note that `parseHandles` may return the same object unmodified now,
wherease before it would always clone (via `JSON.stringify` roundtrip)

---------

Co-authored-by: Alex Villarreal <716334+alexvy86@users.noreply.github.com>
markfields added a commit to markfields/FluidFramework that referenced this pull request May 20, 2024
Fixes microsoft#8016. We need to port this back to RC3 and RC4 once merged to
main.

For anyone implementing their own DDS, when they pick up an FF release
with microsoft#19242 in it, they will likely be in a position where handles are
going through `parseHandles` or `serializer.decode` twice.

We assumed this was idempotent but found that it is not, with two
different codepaths needing to be fixed.

Note that `parseHandles` may return the same object unmodified now,
wherease before it would always clone (via `JSON.stringify` roundtrip)

---------

Co-authored-by: Alex Villarreal <716334+alexvy86@users.noreply.github.com>
kekachmar pushed a commit to kekachmar/FluidFramework that referenced this pull request May 21, 2024
Fixes microsoft#8016. We need to port this back to RC3 and RC4 once merged to
main.

For anyone implementing their own DDS, when they pick up an FF release
with microsoft#19242 in it, they will likely be in a position where handles are
going through `parseHandles` or `serializer.decode` twice.

We assumed this was idempotent but found that it is not, with two
different codepaths needing to be fixed.

Note that `parseHandles` may return the same object unmodified now,
wherease before it would always clone (via `JSON.stringify` roundtrip)

---------

Co-authored-by: Alex Villarreal <716334+alexvy86@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: sharedstring area: dds: tree area: dds Issues related to distributed data structures area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch dependencies Pull requests that update a dependency file public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants