-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(run-engine,run-store,webapp): stop split-mode waits hanging on resume #4164
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
15 commits
Select commit
Hold shift + click to select a range
a8c6323
fix(run-store): commit run snapshots and their completed-waitpoint li…
d-cs 339ed71
fix(run-engine): repair completed-waitpoints from the primary on a st…
d-cs 3c00f14
test(run-store,run-engine): cover dedicated snapshot-write atomicity …
d-cs c2e29ab
test(run-store): assert every lock column rolls back, not just the ru…
d-cs ee99f15
chore(run-store): satisfy oxfmt on the new atomicity test
d-cs 5721351
Merge branch 'main' into fix/run-store-atomic-snapshot-waitpoint-writes
d-cs c2593ef
test(testcontainers): add a lagging-replica client for read-your-writ…
d-cs ff7f461
fix(webapp): read the batch from the primary in the checkpoint WAIT_F…
d-cs 409b057
fix(run-engine,run-store): close run-ops split read and routing gaps …
d-cs d243c41
fix(webapp): read the primary when a waitpoint token misses both read…
d-cs a80466a
fix(run-engine): stop createDateTimeWaitpoint bypassing residency rou…
d-cs 3b09903
chore: satisfy oxfmt on the lagging-replica helper and repro test
d-cs 43d6e33
fix(webapp): scope the waitpoint-token fallback to the run-ops primary
d-cs 3cfa9b3
refactor(run-store): extract the dedicated-schema forbidden-relation …
d-cs a93c6e1
test(webapp): inject a container newPrimary in the not-found waitpoin…
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Unit red-green for the checkpoint WAIT_FOR_BATCH replica-lag fix (createCheckpoint.server.ts). | ||
| // The service decides whether to suspend a run on `batchRun.resumedAt`; reading it from a lagging | ||
| // replica makes a just-resumed batch look unresumed -> it suspends an already-resumed run -> stall. | ||
| // The fix threads the primary (`this._prisma`) into `runStore.findBatchTaskRunByFriendlyId`. Here a | ||
| // spy runStore records which client the service passed and simulates the lag (only the primary read | ||
| // sees the fresh resumedAt): RED = no client -> stale null -> no early return; GREEN = primary -> kept alive. | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| vi.mock("~/services/logger.server", () => ({ | ||
| logger: { debug: vi.fn(), info: vi.fn(), log: vi.fn(), error: vi.fn(), warn: vi.fn() }, | ||
| })); | ||
| vi.mock("~/v3/marqs/index.server", () => ({ | ||
| marqs: { replaceMessage: vi.fn(), cancelHeartbeat: vi.fn() }, | ||
| })); | ||
|
|
||
| import { CreateCheckpointService } from "~/v3/services/createCheckpoint.server"; | ||
|
|
||
| describe("checkpoint WAIT_FOR_BATCH reads the primary, not a lagging replica", () => { | ||
| it("threads the primary so an already-resumed batch keeps the run alive", async () => { | ||
| // A freezable attempt so control reaches the WAIT_FOR_BATCH arm. This object IS the primary the | ||
| // fix must thread into the batch read. | ||
| const prisma = { | ||
| taskRunAttempt: { | ||
| findFirst: async () => ({ | ||
| id: "attempt_1", | ||
| status: "EXECUTING", | ||
| taskRunId: "run_1", | ||
| taskRun: { id: "run_1", status: "EXECUTING", runtimeEnvironmentId: "env_1" }, | ||
| backgroundWorker: { id: "bw_1", deployment: { imageReference: "img:1" } }, | ||
| }), | ||
| }, | ||
| }; | ||
|
|
||
| let seenClient: unknown = "NOT_CALLED"; | ||
| const runStore = { | ||
| findBatchTaskRunByFriendlyId: async ( | ||
| _friendlyId: string, | ||
| _environmentId: string, | ||
| _args: unknown, | ||
| client?: unknown | ||
| ) => { | ||
| seenClient = client; | ||
| // Lagging replica: only a read handed the primary sees the just-committed resumedAt. | ||
| return { resumedAt: client === prisma ? new Date() : null }; | ||
| }, | ||
| }; | ||
|
|
||
| const service = new CreateCheckpointService(prisma as never, {} as never, runStore as never); | ||
|
|
||
| let result: unknown; | ||
| try { | ||
| result = await service.call({ | ||
| attemptFriendlyId: "attempt_1", | ||
| reason: { type: "WAIT_FOR_BATCH", batchFriendlyId: "batch_1" }, | ||
| } as never); | ||
| } catch { | ||
| // Buggy path falls through the pre-check into checkpoint creation (unstubbed) and throws; the | ||
| // recorded client below is what distinguishes RED from GREEN. | ||
| } | ||
|
|
||
| expect(seenClient).toBe(prisma); // the fix: primary threaded into the batch read | ||
| expect(result).toEqual({ success: false, keepRunAlive: true }); // early-return, run kept alive | ||
| }); | ||
| }); | ||
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
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.