Skip to content

Commit 1e352d0

Browse files
committed
fix(run-store): exclude id-less operations from the routed-shard counter
An operation with no id falls back to the default store rather than resolving to one, so counting it as id-routed traffic inflated the default series during a ramp. The counter now fires only when an id resolved the key. Also moves the unroutable-id helper test next to its source.
1 parent befbf79 commit 1e352d0

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

apps/webapp/test/unroutableRead.test.ts renamed to apps/webapp/app/v3/runOpsMigration/unroutableRead.server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { UnknownShardKey } from "@internal/run-store";
22
import { describe, expect, it } from "vitest";
3-
import { undefinedOnUnroutableId } from "~/v3/runOpsMigration/unroutableRead.server";
3+
import { undefinedOnUnroutableId } from "./unroutableRead.server";
44

55
// `RoutingRunStore.findRun` is not async: it resolves the shard and throws before returning
66
// anything, so these stand in for a read that fails while the call expression is still being

internal-packages/run-store/src/runOpsStore.shardMap.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ describe("RoutingRunStore #distinctStores — one entry per database", () => {
420420
expect(routed).toEqual([]);
421421
});
422422

423+
it("does not count an id-less operation against the default store", async () => {
424+
const routed: string[] = [];
425+
const { router } = buildNShardRouter(["a", "b"], { routed });
426+
427+
await router.findRun({ spanId: "s1" }, undefined);
428+
await router.runInTransaction(undefined, async () => undefined);
429+
430+
expect(routed).toEqual([]);
431+
});
432+
423433
it("does not count the legacy leg of an unrouted probe", async () => {
424434
const routed: string[] = [];
425435
const { router } = buildNShardRouter(["a", "b"], { routed });

internal-packages/run-store/src/runOpsStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ export class RoutingRunStore implements RunStore {
486486
}
487487

488488
#routeOrNew(id: string | undefined): RunStore {
489-
return this.#shardStoreRoutedById(this.#routeKeyOrDefault(id));
489+
const key = this.#routeKeyOrDefault(id);
490+
// An absent id fell back to the default store rather than resolving anywhere, so it is not
491+
// traffic attributable to that shard.
492+
return typeof id === "string" ? this.#shardStoreRoutedById(key) : this.#shardStore(key);
490493
}
491494

492495
// WRITE routing is pure id-shape (cuid → LEGACY, run-ops id → NEW). A LEGACY-classified id is

0 commit comments

Comments
 (0)