Repository navigation
fix(memory): hold the remember lock on every memory delete path #1746
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
8 commits
Select commit
Hold shift + click to select a range
bd89c1a
fix(memory): hold the remember lock on every memory delete path
rohitg00 65fec08
Merge remote-tracking branch 'origin/main' into fix/delete-paths-reme…
rohitg00 13a32ea
fix(memory): release images outside the remember lock and drop orphan…
rohitg00 5eae768
fix(retention): finish delete cleanup when an image release fails and…
rohitg00 9f076d3
fix(evict): release the image of the record deleted under the lock
rohitg00 bd2c727
Merge origin/main and re-sync documented counts
rohitg00 35447ed
test(memory): cover the real releaseImageRef failure path
rohitg00 17ca7cd
Merge origin/main and re-sync documented counts
rohitg00 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
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,50 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
|
|
||
| const { warn } = vi.hoisted(() => ({ warn: vi.fn() })); | ||
| vi.mock("../src/logger.js", () => ({ | ||
| logger: { info: vi.fn(), warn, error: vi.fn() }, | ||
| })); | ||
|
|
||
| import { releaseImageRef } from "../src/functions/image-refs.js"; | ||
| import { KV } from "../src/state/schema.js"; | ||
|
|
||
| function kvWithFailingWrite(count: number) { | ||
| return { | ||
| get: async (scope: string) => (scope === KV.imageRefs ? count : null), | ||
| set: async () => { | ||
| throw new Error("image ref write failed"); | ||
| }, | ||
| delete: async () => {}, | ||
| list: async () => [], | ||
| }; | ||
| } | ||
|
|
||
| describe("releaseImageRef", () => { | ||
| beforeEach(() => warn.mockClear()); | ||
|
|
||
| it("logs a failed image ref write and does not throw", async () => { | ||
| const sdk = { trigger: vi.fn() }; | ||
| await expect(releaseImageRef(kvWithFailingWrite(2) as never, sdk as never, "mem_1", "/tmp/img-a.png")).resolves.toBeUndefined(); | ||
| expect(warn).toHaveBeenCalledWith("Image reference release failed after delete", { | ||
| ownerId: "mem_1", | ||
| imageRef: "/tmp/img-a.png", | ||
| error: "image ref write failed", | ||
| }); | ||
| }); | ||
|
|
||
| it("decrements the count when the write succeeds", async () => { | ||
| const writes: Array<[string, string, unknown]> = []; | ||
| const kv = { | ||
| get: async () => 3, | ||
| set: async (scope: string, key: string, value: unknown) => { | ||
| writes.push([scope, key, value]); | ||
| return value; | ||
| }, | ||
| delete: async () => {}, | ||
| list: async () => [], | ||
| }; | ||
| await releaseImageRef(kv as never, { trigger: vi.fn() } as never, "mem_2", "/tmp/img-b.png"); | ||
| expect(writes).toEqual([[KV.imageRefs, "/tmp/img-b.png", 2]]); | ||
| expect(warn).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.