Skip to content

[cache] Make an aborted insert operation call the callback with false#23136

Merged
mattklein123 merged 2 commits intoenvoyproxy:mainfrom
ravenblackx:cache_test
Sep 19, 2022
Merged

[cache] Make an aborted insert operation call the callback with false#23136
mattklein123 merged 2 commits intoenvoyproxy:mainfrom
ravenblackx:cache_test

Conversation

@ravenblackx
Copy link
Copy Markdown
Contributor

Commit Message: [cache] Make an aborted insert operation call the callback with false
Additional Description: The callback's parameter is currently only used in testing (though it could potentially be used to abandon an insert operation early); the previous implementation asserted that the insert callback was called with true, before checking that the insert did not in fact complete, which doesn't really make a lot of sense. The reasonable fixes were either to have the test ignore the callback's value and have it only check that the insert didn't actually happen, or validate that the return value correctly reflects an uncompleted insert operation, which involved also making simple_http_cache fulfill that expectation.
Risk Level: Very low (mostly test-only change to WIP extension)
Testing: Mostly a change to only test-facing behavior.
Docs Changes: n/a
Release Notes: May require a corresponding change to any existing external cache implementations in order for them to pass the generic cache test suite.
Platform Specific Features: n/a

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine. But I'm curious what the callback would do with a 'true' value from insert. That doesn't guarantee a subsequent lookup would pass, right? An eviction might occur immediately after a successful insert.

cache_.insert(key_, std::move(response_headers_), std::move(metadata_), body_.toString(),
std::move(trailers_));
return cache_.insert(key_, std::move(response_headers_), std::move(metadata_),
body_.toString(), std::move(trailers_));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this didn't really change this PR but should we be thinking about a zero-copy way to transfer the body?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think simple_http_cache is just supposed to be an example, not a serious implementation. But also I think zero-copy isn't really an option anyway because the original version is still being used for the response - you can't have one used for the response and a separate one for the cache with no copying. (And you can't use the same one because the response path is going to destroy it.)

@jmarantz
Copy link
Copy Markdown
Contributor

also CI needs to be addressed.

/wait

@ravenblackx
Copy link
Copy Markdown
Contributor Author

Code looks fine. But I'm curious what the callback would do with a 'true' value from insert. That doesn't guarantee a subsequent lookup would pass, right? An eviction might occur immediately after a successful insert.

I don't think there's a strong implication of "true" - it means the part of the insert operation was completed, so [nothing important]. The implication of false, however, is meaningful in that it means the entry wasn't inserted, or was rejected for some reason before even reaching the end of the insert operation, which could potentially allow the filter to stop trying to insert the rest of the same record. (But right now the filter doesn't do anything with the callback parameter's value, it's only used in tests.)

So a "true" response means "don't do that", essentially. :)

@ravenblackx
Copy link
Copy Markdown
Contributor Author

As far as I can tell the CI failures were all a failure to download something, not related to the change. Pushing a non-change to trigger testing again and clear the /wait away.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
@jmarantz
Copy link
Copy Markdown
Contributor

Makes sense to me on all fronts. Thanks.

@ravenblackx
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #23136 (comment) was created by @ravenblackx.

see: more, trace.

@ravenblackx
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #23136 (comment) was created by @ravenblackx.

see: more, trace.

@mattklein123 mattklein123 merged commit 62defb9 into envoyproxy:main Sep 19, 2022
@ravenblackx ravenblackx deleted the cache_test branch September 19, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants