-
Notifications
You must be signed in to change notification settings - Fork 274
chore: Handle too big CH payloads for caching #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
caches: | ||
- name: "longterm" | ||
mode: "file_system" | ||
max_payload_size: "-10B" | ||
file_system: | ||
dir: "cache_dir" | ||
max_size: 100Gb | ||
|
||
server: | ||
http: | ||
listen_addr: ":8080" | ||
|
||
users: | ||
- name: "dummy" | ||
allowed_networks: ["1.2.3.4"] | ||
to_cluster: "cluster" | ||
to_user: "default" | ||
|
||
clusters: | ||
- name: "cluster" | ||
nodes: ["127.0.1.1:8123"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,9 +351,22 @@ func (rp *reverseProxy) serveFromCache(s *scope, srw *statResponseWriter, req *h | |
if err != nil { | ||
err = fmt.Errorf("%s: %w; query: %q", s, err, q) | ||
respondWith(srw, err, http.StatusInternalServerError) | ||
return | ||
} | ||
} else { | ||
// Do not cache responses greater than max payload size. | ||
if contentLength > int64(s.user.cache.MaxPayloadSize) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should complete ongoing transaction even if cache is being skipped There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
cacheSkipped.With(labels).Inc() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test that will check that the maxpayloadSize works for a payload bigger and doesn't work for a payload smaller. One way to check it in the test would be to look at the cacheSkipped counter |
||
log.Infof("%s: Request will not be cached. Content length (%d) is greater than max payload size (%d)", s, contentLength, s.user.cache.MaxPayloadSize) | ||
|
||
rp.completeTransaction(s, statusCode, userCache, key, q) | ||
|
||
err = RespondWithData(srw, reader, contentMetadata, 0*time.Second, tmpFileRespWriter.StatusCode()) | ||
if err != nil { | ||
err = fmt.Errorf("%s: %w; query: %q", s, err, q) | ||
respondWith(srw, err, http.StatusInternalServerError) | ||
} | ||
return | ||
} | ||
cacheMiss.With(labels).Inc() | ||
log.Debugf("%s: cache miss", s) | ||
expiration, err := userCache.Put(reader, contentMetadata, key) | ||
|
Uh oh!
There was an error while loading. Please reload this page.