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

Add the Fix for Missing Ops Log, and telemetry for the Ops from the Last Service Summary #12295

Merged
merged 12 commits into from
Oct 13, 2022
46 changes: 31 additions & 15 deletions server/routerlicious/packages/lambdas/src/scribe/summaryWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ export class SummaryWriter implements ISummaryWriter {
uploadHandle = commit.sha;

await (existingRef ? requestWithRetry(
async () => this.summaryStorage.upsertRef(this.documentId, uploadHandle),
"writeClientSummary_upsertRef",
this.lumberProperties,
shouldRetryNetworkError,
this.maxRetriesOnError) : requestWithRetry(
async () => this.summaryStorage.upsertRef(this.documentId, uploadHandle),
"writeClientSummary_upsertRef",
this.lumberProperties,
shouldRetryNetworkError,
this.maxRetriesOnError) : requestWithRetry(
async () => this.summaryStorage.createRef(this.documentId, uploadHandle),
"writeClientSummary_createRef",
this.lumberProperties,
Expand Down Expand Up @@ -514,19 +514,28 @@ export class SummaryWriter implements ISummaryWriter {
(missingOps.concat(logTail)).sort((op1, op2) => op1.sequenceNumber - op2.sequenceNumber) :
logTail;

// Check the missing operations in the fullLogTail
if (fullLogTail.length !== (to - from - 1)) {
// Check the missing operations in the fullLogTail. We would treat
// isLogtailEntriesMatch as true when the fullLogTail's length is extact same as the requested range.
// As well as the first SN of fullLogTail - 1 is equal to from,
// and the last SN of fullLogTail + 1 is equal to to.
// For example, from: 2, to: 5, fullLogTail with SN [3, 4] is the true scenario.
const isLogtailEntriesMatch = fullLogTail &&
fullLogTail.length > 0 &&
fullLogTail.length === (to - from - 1) &&
from === fullLogTail[0].sequenceNumber - 1 &&
to === fullLogTail[fullLogTail.length - 1].sequenceNumber + 1;
if (!isLogtailEntriesMatch) {
const missingOpsSequenceNumbers: number[] = [];
const fullLogTailSequenceNumbers = fullLogTail.map((ms) => ms.sequenceNumber);
let j = 0;
const fullLogTailSequenceNumbersSet = new Set();
fullLogTail?.map((op) => fullLogTailSequenceNumbersSet.add(op.sequenceNumber));
for (let i = from + 1; i < to; i++) {
if (i === fullLogTailSequenceNumbers[j]) {
j++;
continue;
if (!fullLogTailSequenceNumbersSet.has(i)) {
tianzhu007 marked this conversation as resolved.
Show resolved Hide resolved
missingOpsSequenceNumbers.push(i);
}
missingOpsSequenceNumbers.push(i);
}
Lumberjack.error(`Missing ops in the fullLogTail: ${JSON.stringify(missingOpsSequenceNumbers)}`
Lumberjack.info(
// eslint-disable-next-line max-len
`FullLogTail missing ops from: ${from} exclusive, to: ${to} exclusive with sequence numbers: ${JSON.stringify(missingOpsSequenceNumbers)}`
, this.lumberProperties);
}

Expand Down Expand Up @@ -556,7 +565,14 @@ export class SummaryWriter implements ISummaryWriter {
const logtailSequenceNumbers = new Set();
logTail.forEach((ms) => logtailSequenceNumbers.add(ms.sequenceNumber));
const missingOps = lastSummaryMessages?.filter((ms) =>
!(logtailSequenceNumbers.has(ms.sequenceNumber)));
!(logtailSequenceNumbers.has(ms.sequenceNumber)) && ms.sequenceNumber > gt && ms.sequenceNumber < lt);
const missingOpsSN: number[] = [];
missingOps?.forEach((op) => missingOpsSN.push(op.sequenceNumber));
if (missingOpsSN.length > 0) {
// eslint-disable-next-line max-len
Lumberjack.info(`Fetched ops gt: ${gt} exclusive, lt: ${lt} exclusive of last summary logtail: ${JSON.stringify(missingOpsSN)}`
, this.lumberProperties);
}
return missingOps;
}

Expand Down