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

Stop using short data store IDs in detached container #21613

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

agarwal-navin
Copy link
Contributor

Bug

Currently, data stores created in detached container always get a short ID via id compressor. We have a bug in one of our customer's app where a short data store ID created is [ but in a downloaded snapshot, it is converted to its ASCII equivalent %5B in certain conditions. So, when an op comes for this data store with id [, containers loaded with this snapshot cannot find the data store.

Root-cause

We haven't yet identified what causes the id to change from [ -> %5B. However, we know that it is caused by short IDs generated in detached container.

Fix

To mitigate the issue for customers, this PR disables the generation of short IDs for data stores and DDSes. Added tests that validate that we don't generate short IDs for data stores and DDSes in detached or attached state.

@agarwal-navin agarwal-navin requested review from vladsud, markfields, a team, pragya91, jatgarg, tyler-cai-microsoft, kian-thompson and rajatch-ff and removed request for a team June 25, 2024 19:52
@github-actions github-actions bot added area: runtime Runtime related issues area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch labels Jun 25, 2024
*
* While we figure out the fix, we are disabling the ability to create short IDs and this assert validates it.
*/
function assertInvert(value: unknown, message: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it's unknown, not boolean type? All the cases seem to be boolean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to boolean

assert(typeof idTest === "number", "short IDs should be issued");
assert(idTest >= 0, "finalId");
assertInvert(typeof idTest === "number", "short IDs should be issued");
// assert(idTest >= 0, "finalId");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe be roll it into previous assert? I.e.

assertInvert(typeof idTest === "number" && idTest >= 0, "short IDs should be issued");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const dataStore1 =
await defaultDataStore.context.containerRuntime.createDataStore(TestDataObjectType);
const ds1 = (await dataStore1.entryPoint.get()) as ITestFluidObject;
assertInvert(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change this test and create 100 of detached data stores?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could but I don't see a point. Are you suggesting we the load a container and basically validate that it can load all these data stores, process ops, etc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah you need 13 to create a datastore with id "["

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but there is no repro of the issue even with that. So, I don't see a point in doing it yet. Once we have a repro, we can add test for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Working on it

Copy link
Contributor

Choose a reason for hiding this comment

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

this.dataStoreContext.containerRuntime.generateDocumentUniqueId?.() ?? uuid();
id = typeof res === "number" ? encodeCompactIdToString(2 * res + 1, "_") : res;
}
// if (this.visibilityState !== VisibilityState.GloballyVisible) {
Copy link
Contributor

@rajatch-ff rajatch-ff Jun 25, 2024

Choose a reason for hiding this comment

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

Should we put all of these changes behind a feature flag, for easy toggles in DF/PROD?

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 am not sure I see the value in doing that because we can't enable it unless we fix the bug which will require making code changes anyway. We can enable it via that change and add feature flags if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I hear you there. Feature flag might come handy, if the issue happens to be on ODSP side, and we can just toggle our change off without making a code change. Since the true-root-cause is still being figured out, there may be value in keeping this change behind a switch.

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 can add it behing a feature. But I doubt we will use it (Loop would probably not let us it being so risky). Also, we heard from ODSP that it's not their issue most likely.
Let me work on adding a feature, it doesn't hurt :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added feature flags

@rajatch-ff
Copy link
Contributor

Any side-effects of turning off short-ids that we should know about or consider before merging?

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Jun 25, 2024

@fluid-example/bundle-size-tests: +806 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 451.81 KB 452 KB +195 Bytes
azureClient.js 550.39 KB 550.59 KB +209 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 255.73 KB 255.82 KB +95 Bytes
fluidFramework.js 384.76 KB 384.77 KB +14 Bytes
loader.js 133.46 KB 133.47 KB +14 Bytes
map.js 41.1 KB 41.11 KB +7 Bytes
matrix.js 143.38 KB 143.38 KB +7 Bytes
odspClient.js 518.46 KB 518.66 KB +209 Bytes
odspDriver.js 97.21 KB 97.23 KB +21 Bytes
odspPrefetchSnapshot.js 42.21 KB 42.22 KB +14 Bytes
sharedString.js 159.88 KB 159.89 KB +7 Bytes
sharedTree.js 375.22 KB 375.23 KB +7 Bytes
Total Size 3.23 MB 3.23 MB +806 Bytes

Baseline commit: d2ba7eb

Generated by 🚫 dangerJS against fd8f56d

@markfields markfields changed the title Added id compressor tests to validate that data store IDs are always short in detached container Stop using short data store IDs in detached container Jun 25, 2024
@agarwal-navin
Copy link
Contributor Author

Any side-effects of turning off short-ids that we should know about or consider before merging?

AFAIK, there shouldn't be. I will defer to @vladsud to double check.

@vladsud
Copy link
Contributor

vladsud commented Jun 25, 2024

We are not attempting to recover existing documents. Change impacts new documents only (it will make them work again).

@agarwal-navin agarwal-navin merged commit 1c00d7e into microsoft:main Jun 25, 2024
30 checks passed
agarwal-navin added a commit to agarwal-navin/FluidFramework that referenced this pull request Jun 25, 2024
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
agarwal-navin added a commit to agarwal-navin/FluidFramework that referenced this pull request Jun 25, 2024
## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
pragya91 pushed a commit to pragya91/FluidFramework-1 that referenced this pull request Jun 25, 2024
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
daesunp pushed a commit that referenced this pull request Jun 25, 2024
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.

(cherry picked from commit 1c00d7e)
pragya91 pushed a commit to pragya91/FluidFramework-1 that referenced this pull request Jun 26, 2024
## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
agarwal-navin added a commit that referenced this pull request Jun 26, 2024
…21613) (#21628)

Porting
1c00d7e
to rc 3 branch.

## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is [ but in a downloaded snapshot, it is
converted to its ASCII equivalent %5B in certain conditions. So, when an
op comes for this data store with id [, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from [ -> %5B.
However, we know that it is caused by short IDs generated in detached
container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
daesunp added a commit that referenced this pull request Jun 26, 2024
…21613) (#21631)

Porting
1c00d7e
to rc 2 branch.

## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.

---------

Co-authored-by: Navin Agarwal <45832642+agarwal-navin@users.noreply.github.com>
rohandubal pushed a commit that referenced this pull request Jun 26, 2024
) (#21629)

Porting
1c00d7e
to 2.0 branch.

## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is [ but in a downloaded snapshot, it is
converted to its ASCII equivalent %5B in certain conditions. So, when an
op comes for this data store with id [, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from [ -> %5B.
However, we know that it is caused by short IDs generated in detached
container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
pragya91 added a commit that referenced this pull request Jun 26, 2024
…21613) (#21630)

Porting
1c00d7e
to RC4.0 branch.

## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is [ but in a downloaded snapshot, it is
converted to its ASCII equivalent %5B in certain conditions. So, when an
op comes for this data store with id [, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from [ -> %5B.
However, we know that it is caused by short IDs generated in detached
container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.

---------

Co-authored-by: Navin Agarwal <45832642+agarwal-navin@users.noreply.github.com>
pragya91 added a commit that referenced this pull request Jun 26, 2024
…21613) (#21632)

Porting
1c00d7e
to rc5 branch.

## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.

Co-authored-by: Navin Agarwal <45832642+agarwal-navin@users.noreply.github.com>
rohandubal pushed a commit that referenced this pull request Jun 26, 2024
## Bug
Currently, data stores created in detached container always get a short
ID via id compressor. We have a bug in one of our customer's app where a
short data store ID created is `[` but in a downloaded snapshot, it is
converted to its ASCII equivalent `%5B` in certain conditions. So, when
an op comes for this data store with id `[`, containers loaded with this
snapshot cannot find the data store.

## Root-cause
We haven't yet identified what causes the id to change from `[` ->
`%5B`. However, we know that it is caused by short IDs generated in
detached container.

## Fix
To mitigate the issue for customers, this PR disables the generation of
short IDs for data stores and DDSes. Added tests that validate that we
don't generate short IDs for data stores and DDSes in detached or
attached state.
@agarwal-navin agarwal-navin deleted the shortIdTest branch July 15, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants