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

[r11s] Fixing SummaryReader for wholeSummaryUpload: accessing map properties correctly #8864

Merged
merged 3 commits into from Jan 27, 2022

Conversation

hedasilv
Copy link
Contributor

SummaryReader is used to read summaries from storage. When SummaryReader tries to readLastSummary() for the first time, that is, before Scribe has written any summaries, it will just find the blank/initial summary that Alfred uploaded. In that case, there is no .serviceProtocol tree, and the operation is expected to fail, thus returning SummaryReader's getDefaultSummaryState().

However, we noticed that when WholeSummaryUpload was enabled, other calls to readLastSummary() would also fail, but due to a different reason. That was because normalizedSummary.blobs is a Map<string, ArrayBuffer> and we were trying to access the map contents with map[key]. That is not correct, as TS would interpret that as accessing the property key of the object. As a result, values like attributesContent would be undefined and that would cause errors later when using bufferToString().

The solution is to instead use map.get(key) to access the map properties appropriately.

@github-actions github-actions bot added the area: server Server related issues (routerlicious) label Jan 25, 2022
Comment on lines 45 to 48
if (!scribeBlobId && !deliBlobId && !opsBlobId) {
summaryReaderMetric.success(`Returning default summary when trying to read initial whole summary`);
return this.getDefaultSummaryState();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We are making an assumption that either all three of them are present or none. This might be true today but I am not sure whether we should rely on it. Rather than doing that, we can only return default values for missing stuff. For example, "messages" in ILatestSummaryState comes from ".logtail" blob. So if logtail is missing, we only use the default value of messages field but use the rest from deli and scribe blob.

But I am okay if we check in this one for now and open a new one for filling specific field.

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. I tried to accomplish that in the latest iteration. The part I'm not sure about now is fromSummary: true in the ILatestSummaryState. Now, it might not be 100% true that the data being read is from the actual summary. Is that a concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe fromSummary needs to be true (https://github.com/microsoft/FluidFramework/blob/main/server/routerlicious/packages/lambdas/src/scribe/lambdaFactory.ts#L125). Otherwise we will return the whole DefaultScribe object. Double-check just to be confirmed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct - and that would also cause trouble to the lambda:

I will leave that as is then :)

@hedasilv hedasilv merged commit 52bfc9d into main Jan 27, 2022
@hedasilv hedasilv deleted the hedasilv/fixMapAccessSummaryReader branch January 27, 2022 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: server Server related issues (routerlicious)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants