Pass cache options to spancache.Get#1531
Merged
Merged
Conversation
sondavidb
reviewed
Apr 25, 2025
Before this change, the span manager did not pass cache opts to the span cache when getting keys, but it did pass options when putting keys. This change makes them consistent. This is problematic with the Direct option because writes are directly to files, but reads use a file descriptor cache. This leads to the following issue: 1. The background fetcher fetches a span, but does not decompress it 2. The background fetcher writes the compressed span to the span cache 3. A later read loads the compressed data from the span cache. This caches the file descriptor 4. The span is decompressed 5. The span is rewritten to the same cache key by opening a temp file, writing the decompressed span data, then renaming it to the original name. NOTE: This is a different file descriptor from step 3! 6. The span is marked decompressed 7. Another read hits in the cache and get's back the fd to the (now deleted) compressed file from step 3. 8. SOCI returns compressed data or get's an unxpected EOF because there isn't as much compressed data as uncompressed data. The solution here is to pass cache options. Each cache Get opens a new file descriptor, so the caching issue is bypassed. Signed-off-by: Kern Walster <walster@amazon.com>
46c5a37 to
e049f8e
Compare
swagatbora90
approved these changes
Apr 25, 2025
austinvazquez
approved these changes
Apr 25, 2025
sondavidb
approved these changes
Apr 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Before this change, the span manager did not pass cache opts to the span cache when getting keys, but it did pass options when putting keys. This change makes them consistent.
This is problematic with the Direct option because writes are directly to files, but reads use a file descriptor cache. This leads to the following issue:
The solution here is to pass cache options. Each cache Get opens a new file descriptor, so the caching issue is bypassed.
This was exposed by #1512 because we stopped using the go-toml default values which included
DirectoryCacheConfig.Directwhich was true. We should move the go-toml default values into config parsers because go-toml defaults are deprecated in v2.0. It's a default=true config value which will be easier to add after #1518Testing performed:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.