Fix missing external memory accounting for OutgoingFactory fetchers#6209
Fix missing external memory accounting for OutgoingFactory fetchers#6209
Conversation
|
Let me now do a final check: is Looking at the header we already read: struct ClientWithTracing {
kj::Own<WorkerInterface> client;
kj::Maybe<TraceContext> traceContext;
};Yes, it's Now let me analyze if there are any issues:
However, I want to flag one concern: the proxy variable Actually, wait - is there a more direct concern? Let me re-check: in if (util::Autogate::isEnabled(util::AutogateKey::INCREASE_EXTERNAL_MEMORY_ADJUSTMENT_FOR_FETCH)) {
KJ_IF_SOME(lock, currentLock) {
jsg::Lock& js = lock;
ret = ret.attach(js.getExternalMemoryAdjustment(8 * 1024));
}
}If However, in The code change is correct and well-reasoned. The only minor issue is that using LGTM |
Motivation
IoContext::getSubrequestNoChecks(), butOutgoingFactory-backed fetchers can bypass that path and thus stopped receiving any external memory accounting when the autogate is enabled, risking unaccounted C++ memory growth and OOM/DoS.Description
fetch()obtained its client via the subrequest/traced path by checkingclientWithTracing.traceContextand record this inhasSubrequestAdjustment.INCREASE_EXTERNAL_MEMORY_ADJUSTMENT_FOR_FETCHis disabled by keeping the 3 KiB per-fetch adjustment.fetchImplNoOutputLock()only for clients that bypass the subrequest/tracing path (i.e.,OutgoingFactoryfetchers) to avoid double-accounting and close the accounting gap.src/workerd/api/http.c++(local change committed).Testing
bazel query) and other Bazel-backed tests, but the environment could not download the Bazel binary (HTTP forbidden), so no automated Bazel tests were executed.Codex Task