AlinsRan commented on code in PR #14061:
URL: https://github.com/apache/apisix/pull/14061#discussion_r4346883717
##########
apisix/plugins/oas-validator.lua:
##########
@@ -234,11 +281,16 @@ local function get_validator(conf)
end
cache_key = cache_key .. "#" .. ngx_md5(tab_concat(parts, "&"))
end
- local validator, err = lrucache(cache_key, nil, fetch_and_compile, conf)
- if not validator then
+
+ -- Key by the declaring resource with the URL key as version, so a changed
+ -- spec_url replaces the resource's slot instead of adding another one.
+ local entry, err = lrucache(conf._meta.parent.resource_key, cache_key,
+ create_spec_url_entry, conf, cache_key,
+ spec_url_lrucache_ttl)
Review Comment:
When a resource reuses a shared document, its cache slot gets a full TTL,
even if the document is about to expire. Subsequent cache hits bypass the
`fetched_at` check.
With a one-second TTL:
- At t=0, route A fetches the document.
- At t=0.65, route B reuses it and gets a cache slot valid until t=1.65.
- At t=1.2, a request to B still hits that slot, although the document is
already older than the configured TTL.
That request does not schedule a background refresh. On the base version,
the same request triggers a refresh, and the document is fetched again when the
refresh callback runs.
As a result, B can continue validating requests against an outdated
specification for nearly an extra TTL—almost an hour with the default setting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]