-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(webapp,run-ops-database): keep run-ops batch items co-resident with their batch #4178
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4021096
fix(webapp): anchor batch item run-ops residency to the batch friendlyId
d-cs 6e1b607
test(run-ops-database): verify real bidirectional schema parity
d-cs e9ee072
fix(webapp): signal when run-ops split read fan-out is silently disabled
d-cs d3cf9ff
Merge branch 'main' into fix/run-ops-split-hardening
d-cs efd56f7
chore(webapp): drop redundant server-changes entry for the read fan-o…
d-cs 149909d
refactor(webapp,run-ops-database): address bot review feedback
d-cs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: fix | ||
| --- | ||
|
|
||
| Anchor batch item run-ops residency on the batch's own friendlyId (not a fresh per-org flag read) in the run-engine batch trigger service and the BatchQueue item callback, on both the success path and the pre-failed-run failure path, so a mid-batch mint-flag flip can no longer mint an item (or a pre-failed item) into a different physical store than its BatchTaskRun row. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
apps/webapp/app/runEngine/services/triggerFailedTask.server.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| // Empty singletons satisfy the module-level wiring imports; the mint method under test is driven | ||
| // directly via (service as any) and never touches the DB (same boundary as triggerTask.server.test.ts). | ||
| vi.mock("~/db.server", () => ({ | ||
| prisma: {}, | ||
| $replica: {}, | ||
| runOpsNewPrisma: {}, | ||
| runOpsLegacyPrisma: {}, | ||
| runOpsNewReplica: {}, | ||
| runOpsLegacyReplica: {}, | ||
| })); | ||
| vi.mock("~/v3/runOpsMigration/splitMode.server", () => ({ isSplitEnabled: async () => false })); | ||
|
|
||
| import { classifyKind, generateRunOpsId, RunId } from "@trigger.dev/core/v3/isomorphic"; | ||
| import { TriggerFailedTaskService } from "./triggerFailedTask.server"; | ||
|
|
||
| function buildService() { | ||
| return new TriggerFailedTaskService({ prisma: {} as any, engine: {} as any }); | ||
| } | ||
|
|
||
| describe("TriggerFailedTaskService.mintFailedRunFriendlyId", () => { | ||
| it("returns the caller-supplied runFriendlyId verbatim (override wins over any mint)", async () => { | ||
| const override = RunId.toFriendlyId(generateRunOpsId()); | ||
| const minted = await (buildService() as any).mintFailedRunFriendlyId({ | ||
| organizationId: "org_1", | ||
| environmentId: "env_1", | ||
| runFriendlyId: override, | ||
| }); | ||
| expect(minted).toBe(override); | ||
| }); | ||
|
|
||
| it("without an override, still inherits a run-ops (NEW) parent by id-shape", async () => { | ||
| const parentRunFriendlyId = RunId.toFriendlyId(generateRunOpsId()); | ||
| const minted = await (buildService() as any).mintFailedRunFriendlyId({ | ||
| organizationId: "org_1", | ||
| environmentId: "env_1", | ||
| parentRunFriendlyId, | ||
| }); | ||
| expect(classifyKind(minted)).toBe("runOpsId"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
apps/webapp/app/v3/runOpsMigration/mintAnchoredRunFriendlyId.server.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { | ||
| BatchId, | ||
| classifyKind, | ||
| generateRunOpsId, | ||
| parseRunId, | ||
| REGION_CODES, | ||
| } from "@trigger.dev/core/v3/isomorphic"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { mintAnchoredRunFriendlyId } from "./mintAnchoredRunFriendlyId.server"; | ||
|
|
||
| describe("mintAnchoredRunFriendlyId", () => { | ||
| it("a run-ops (NEW) batch anchor yields a run-ops (NEW) item friendlyId", () => { | ||
| const batchFriendlyId = BatchId.toFriendlyId(generateRunOpsId()); | ||
| const itemFriendlyId = mintAnchoredRunFriendlyId(batchFriendlyId); | ||
| expect(classifyKind(itemFriendlyId)).toBe("runOpsId"); | ||
| }); | ||
|
|
||
| it("a cuid (LEGACY) batch anchor yields a cuid (LEGACY) item friendlyId", () => { | ||
| const batchFriendlyId = BatchId.generate().friendlyId; | ||
| const itemFriendlyId = mintAnchoredRunFriendlyId(batchFriendlyId); | ||
| expect(classifyKind(itemFriendlyId)).toBe("cuid"); | ||
| }); | ||
|
|
||
| it("stamps the requested region char into a run-ops id", () => { | ||
| const batchFriendlyId = BatchId.toFriendlyId(generateRunOpsId()); | ||
| const itemFriendlyId = mintAnchoredRunFriendlyId(batchFriendlyId, "us-east-1"); | ||
| const parsed = parseRunId(itemFriendlyId); | ||
| expect(parsed.format).toBe("b32hex"); | ||
| expect(parsed.format === "b32hex" && parsed.region).toBe(REGION_CODES["us-east-1"]); | ||
| }); | ||
| }); |
15 changes: 15 additions & 0 deletions
15
apps/webapp/app/v3/runOpsMigration/mintAnchoredRunFriendlyId.server.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { generateRunOpsId, RunId, type ResidencyKind } from "@trigger.dev/core/v3/isomorphic"; | ||
| import { resolveInheritedMintKind } from "./resolveInheritedMintKind.server"; | ||
|
|
||
| // Shared id-generation branch for every run-mint path: "runOpsId" -> NEW store, "cuid" -> LEGACY. | ||
| export function mintFriendlyIdForKind(mintKind: ResidencyKind, region?: string): string { | ||
| return mintKind === "runOpsId" | ||
| ? RunId.toFriendlyId(generateRunOpsId(region)) | ||
| : RunId.generate().friendlyId; | ||
| } | ||
|
|
||
| // Anchor a batch item's mint on the BATCH's friendlyId (id-shape, zero I/O), never the per-org | ||
| // flag, so the item and its BatchTaskRun stay co-resident across a mid-batch flag flip. | ||
| export function mintAnchoredRunFriendlyId(batchFriendlyId: string, region?: string): string { | ||
| return mintFriendlyIdForKind(resolveInheritedMintKind(batchFriendlyId), region); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.