Skip to content

Commit

Permalink
add message count comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Dec 13, 2024
1 parent d86b66b commit 7b75406
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/shuttle/src/shuttle/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,39 @@ export class Migration {
return result;
}

async compareMessageCounts(fid: number) {
const hubCounts = await this.hubClient.getCurrentStorageLimitsByFid({ fid });

if (hubCounts.isErr()) {
return err(hubCounts.error);
}

const snapchainCounts = await this.snapchainClient.getCurrentStorageLimitsByFid({ fid });

if (snapchainCounts.isErr()) {
return err(snapchainCounts.error);
}

const hubUsages = new Map();
for (const limits of hubCounts.value.limits) {
hubUsages.set(limits.name, limits.used);
}

const snapchainUsages = new Map();
for (const limits of snapchainCounts.value.limits) {
snapchainUsages.set(limits.name, limits.used);
}

for (const [name, hubUsage] of hubUsages.entries()) {
const snapchainUsage = snapchainUsages.get(name);
if (hubUsage !== snapchainUsage) {
log.info(`USAGE MISMATCH: type: ${name}, hub usage: ${hubUsage}, snapchain usage ${snapchainUsage}`);
}
}

return ok(undefined);
}

async ingestMessagesFromDb(fids: number[]) {
for (const fid of fids) {
let numMessages = 0;
Expand Down Expand Up @@ -285,6 +318,11 @@ export class Migration {
log.info(
`Submitted ${numMessages} messages for fid ${fid}. ${numErrorsOnHub} hub errors. ${numErrorsOnSnapchain} snapchain errors. ${numMessagesPruned} pruned on hub. Skipped ${numSkipped}.`,
);

const compareResult = await this.compareMessageCounts(fid);
if (compareResult.isErr()) {
log.info(`Error comparing message counts ${compareResult.error}`);
}
}
}
}
Expand Down

0 comments on commit 7b75406

Please sign in to comment.