Skip to content

fix(agent): raise the Windows lock quota when key pages run out - #1623

Merged
AnthonyRonning merged 1 commit into
masterfrom
fix/windows-key-lock-quota
Nov 17, 2026
Merged

AnthonyRonning merged 1 commit into
masterfrom
fix/windows-key-lock-quota

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On #1621, a CI-only change, three replay tests failed in the same second on agent-full-windows (run) with Io { kind: PermissionDenied } from Store::capture_replay:

  • encrypted_ephemeral_scratch_is_removed_on_explicit_close_and_drop
  • captured_rows_do_not_pin_obsolete_epoch_rows_or_consult_the_new_epoch
  • cancellation_and_store_close_revoke_scratch_before_reuse

Cause (best-supported hypothesis, not reproduced)

Every LockedKey locks one page with VirtualLock. 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 is KeyError::MemoryLock, which key_buffer_error turns into Io { kind: PermissionDenied }, the exact error the tests saw. Keying the replay scratch database (key_connection in Spool::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 PermissionDenied sources 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 VirtualLock fails, 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 gets MemoryLock.

Verification

  • New test many_keys_can_be_held_at_once holds 512 keys. It passes on macOS locally.
  • The Windows code was not compiled or run locally. This PR carries ci:windows so agent-windows (Clippy) and agent-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


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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]>
@AnthonyRonning AnthonyRonning added the ci:windows Run Windows checks on this PR label Nov 16, 2026
@AnthonyRonning
AnthonyRonning merged commit 36e0235 into master Nov 17, 2026
25 checks passed
@AnthonyRonning
AnthonyRonning deleted the fix/windows-key-lock-quota branch November 17, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:windows Run Windows checks on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant