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

Enhance reliability of obtaining colletion from interval #16251

Conversation

clarenceli-msft
Copy link
Contributor

@clarenceli-msft clarenceli-msft commented Jul 5, 2023

Description

AB#4524, AB#4081

This PR implements enhancements to improve the reliability of obtaining interval collections from intervals. Following discussions with @scarlettjlee, we concluded that directly making the properties private is not feasible since we need to ensure the existing data at rest continue to work. As a result, several compromise strategies are included in this PR:

  1. Prevent overwriting the collection label when adding intervals or explicitly changing properties, it is for the purposes:
  • Each interval should only ever be in one collection, their labels should be consistent

  • We encourage users to create/add an interval based on existing collection, rather than creating random interval and insert them into collections

2. Add a new API to ISerializableInterval to get the labels, allowing users to retrieve the labels similar to getIntervalId(). We discourage users to get access to the properties directly, despite they are public.

@clarenceli-msft clarenceli-msft requested review from msfluid-bot and a team as code owners July 5, 2023 22:14
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: sharedstring public api change Changes to a public API labels Jul 5, 2023
@github-actions github-actions bot added the base: main PRs targeted against main branch label Jul 5, 2023
@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Jul 5, 2023

@fluid-example/bundle-size-tests: +491 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 453.38 KB 453.62 KB +247 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 243.06 KB 243.06 KB No change
loader.js 150.73 KB 150.73 KB No change
map.js 46.75 KB 46.75 KB No change
matrix.js 147.51 KB 147.51 KB No change
odspDriver.js 93.25 KB 93.25 KB No change
odspPrefetchSnapshot.js 44.13 KB 44.13 KB No change
sharedString.js 164.15 KB 164.38 KB +244 Bytes
sharedTree2.js 246.31 KB 246.31 KB No change
Total Size 1.71 MB 1.71 MB +491 Bytes

Baseline commit: 695bb1d

Generated by 🚫 dangerJS against b364d94

/**
* {@inheritDoc ISerializableInterval.getRangeLabels}
*/
public getRangeLabels(): string[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this PR needs to change the public API of intervals. It looks like we already store the collection label name as an interval prop and correctly strip this at serialization time + populate it at deserialization time. The work item linked is more about making sure application code doesn't modify this value as a call to changeProperties (which it looks like you do have that logic). We should still be able to retrieve it using the same logic we did before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose the collection label and interval id have some similarities as they are both stored as interval props reservedRangeLabelKeys and reservedIntervalIdKey, and we do not want them to be modified explicitly. So I suppose it mihgt be a better practice to implement an API having similar purpose with getIntervalId()? Not sure if the benefit of adding it can outweigh the potential drawbacks

Copy link
Contributor

Choose a reason for hiding this comment

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

getIntervalId is also a useful API that applications need to call though--this one it's not clear that we have any external users that want it, so I'd rather avoid cluttering the API surface unless we get specific, reasonable feedback that it's necessary for some scenario.

@github-actions github-actions bot removed the public api change Changes to a public API label Jul 7, 2023
// This check is intended to prevent scenarios where a random interval is created and then
// inserted into a collection. The aim is to ensure that the collection is created first
// then the user can create/add intervals based on the collection
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think our error message here needs to be particularly friendly. asserting here and below might give better bundle size. not a big deal though.

@clarenceli-msft clarenceli-msft merged commit ed08d13 into microsoft:main Jul 7, 2023
29 checks passed
@clarenceli-msft clarenceli-msft deleted the add-method-getting-collection-from-interval branch July 7, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: sharedstring area: dds Issues related to distributed data structures base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants