Repository navigation
fix(agent): raise the Windows lock quota when key pages run out - #1623
Merged
Merged
Conversation
Every LockedKey locks one page. Windows lets a process lock only its
minimum working set less a small overhead, a few dozen pages by default,
so a process holding many keys at once could fail to lock the next one.
That surfaces as KeyError::MemoryLock, which the store reports as
Io { kind: PermissionDenied }.
Three replay tests failed that way in the same second on the Windows
suite (run 43966558979). When VirtualLock fails, grow the minimum
working set by 1 MiB, up to 64 MiB, and try again.
The new test holds 512 keys at once.
Co-Authored-By: Claude <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On #1621, a CI-only change, three replay tests failed in the same second on
agent-full-windows(run) withIo { kind: PermissionDenied }fromStore::capture_replay:encrypted_ephemeral_scratch_is_removed_on_explicit_close_and_dropcaptured_rows_do_not_pin_obsolete_epoch_rows_or_consult_the_new_epochcancellation_and_store_close_revoke_scratch_before_reuseCause (best-supported hypothesis, not reproduced)
Every
LockedKeylocks one page withVirtualLock. Windows lets a process lock only its minimum working set less a small overhead, which is a few dozen pages by default. A process holding many keys at once, such as the parallel test run with its open stores and replay scratch keys, can fail to lock the next one. That isKeyError::MemoryLock, whichkey_buffer_errorturns intoIo { kind: PermissionDenied }, the exact error the tests saw. Keying the replay scratch database (key_connectioninSpool::create) allocates a second locked page per capture.I did not reproduce the original failure, and the log does not say which call returned the error. The other
PermissionDeniedsources in that path are file creation and ACL calls on a fresh per-test temp folder, which would not fail in three tests at once.This is not only a test problem: the app holds the same kind of keys and never raised the quota.
Fix
When
VirtualLockfails, grow the process's minimum working set by 1 MiB and try again, one thread at a time. Growth stops at 64 MiB so a key leak cannot pin memory without bound; past that the caller still getsMemoryLock.Verification
many_keys_can_be_held_at_onceholds 512 keys. It passes on macOS locally.ci:windowssoagent-windows(Clippy) andagent-full-windows(the suite, with the new test) check it. If the new test passes there, the quota raise works; it does not by itself prove the quota caused the original failure.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.