replay: HTTP, HTTP/2 and MySQL data mocks stay in the agent's RAM for the whole run, so a long recording can OOM the replay agent
What happens
With default settings, the replay agent keeps every HTTP, HTTP/2 and MySQL data mock in RAM for the whole replay. Only per-test mocks go to the agent's on-disk store (DiskMocks, #4350), and with the defaults these kinds' data mocks aren't per-test. For an app whose dependencies are mostly HTTP or MySQL, the agent's resident memory therefore grows with the length of the recording. A long recording can OOM-kill the replay agent before its app starts, the same failure a Mongo-backed recording hit through the staging load.
Why
- What the recorders write. MySQL tags data commands
mocks(pkg/agent/proxy/integrations/mysql/recorder/record_v2.go:1865;COM_STMT_PREPAREgetsconnection). HTTP tags exchangesHTTP_CLIENT, and HTTP/2 tags themHTTP2_CLIENT. - How that becomes a session mock.
DeriveLifetime(pkg/models/lifetime.go:296-305) makes any non-configtag on a kind inkindsWithImplicitSessionLifetime(:435-441: HTTP, HTTP2, MySQL, Postgres, PostgresV2, Generic, DNS) aLifetimeSession. The only exception is whenKEPLOY_STRICT_MOCK_WINDOWis set to an enabling value. The comment says this preserves the pre-Phase-2 implicit reusability. - Session mocks are always resident. They travel in the stream's unfiltered section, which
StoreMocksStream(pkg/service/agent/agent.go) always keeps in RAM. Only per-test mocks with valid timestamps can go to disk (EligibleForDisk,pkg/agent/proxy/diskmocks.go:78). - Result sets are never stored apart. Even as per-test mocks, MySQL result sets would not be kept apart from their request:
EligibleForResponseSpill(diskmocks.go:92) covers HTTP bodies of 8 KB or more and Mongo only.
The lifetime is derived by the process that reads the mock files, which is the replayer (the k8s-proxy controller for auto-replay). It then travels to the agent with each mock. In the record-prod deployment neither the controller nor the replay pods set KEPLOY_STRICT_MOCK_WINDOW (checked 2026-10-15), so this fallback is live there.
Where it was seen
Found by reading the code during the RCA of the record-prod auto-replay OOM. That recording is Mongo-backed, so this path wasn't the cause there. In its last round, 2,230 mocks stayed resident and 81,738 per-test mocks went to disk. No HTTP- or MySQL-heavy recording has been measured yet, so how fast the agent's memory grows for those is still open.
Possible fixes
- Set
KEPLOY_STRICT_MOCK_WINDOW=1where the replayer runs. HTTP, HTTP/2 and MySQL data mocks then become per-test and go to disk. Before doing that:- MySQL data mocks stop being reusable across tests.
- The HTTP/2 matcher reads only
GetSessionMocks(integrationspkg/http2/match.go:43), and the SQS matcher reads only the session tree. Their data mocks would become unreachable, so those matchers have to read the per-test tier first.
- Take MySQL, and possibly HTTP and HTTP/2, out of the lax fallback for explicitly tagged data mocks. Keep reuse only for input-independent commands, as
COM_PING,COM_STATISTICS,COM_DEBUGandCOM_RESET_CONNECTIONalready are. - Store MySQL result sets apart from their requests, as Mongo responses are, so a loaded window holds only requests until a mock is served.
- Index the on-disk store by request shape (kind plus command or method and path), so reusable mocks can live on disk and be read on demand.
Any of these needs a run of the MySQL, HTTP/2 and SQS sample lanes before it ships, plus a measurement of agent memory on a long MySQL- or HTTP-heavy recording.
/claim
@Aditya-eddy is this issue open for a PR