-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(metrics): Add method namespacing to indexer cache #58178
Conversation
a32f323
to
b84fc21
Compare
b84fc21
to
ab89fae
Compare
ab89fae
to
dbc9960
Compare
Codecov Report
@@ Coverage Diff @@
## master #58178 +/- ##
========================================
Coverage 80.57% 80.57%
========================================
Files 5144 5146 +2
Lines 224845 225018 +173
Branches 37898 37923 +25
========================================
+ Hits 181166 181310 +144
- Misses 38143 38168 +25
- Partials 5536 5540 +4
|
dbc9960
to
a368310
Compare
a368310
to
0dfad70
Compare
I think some more context is needed in the PR description:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Volo, it would be smart to document the rollout/rollback plan for this. When you enable the new namespaces you will effectively be deleting all the existing keys. What are the implications of that? Rolling back will have a similar problem: the data will be split between two keys. What happens when the cache switches back and starts using the old keys?
(Agree with the points regarding documentation above). Overall this looks good to me. From my understanding, the local cache for testing is a Dummy, but I wonder if there's a way around that for testing this locally. If it is not ultimately possible, I think the documentation points above will be quite helpful to have. |
@volokluev @evanh I updated the description let me know if this make more sense! |
0dfad70
to
c3eab94
Compare
c3eab94
to
740ca29
Compare
740ca29
to
d73c1b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes more sense, thank you!
d73c1b9
to
5e76277
Compare
5e76277
to
57e4ecf
Compare
57e4ecf
to
90c62ae
Compare
90c62ae
to
3caa6a1
Compare
) # This PR - Read the sentry option `sentry-metrics.indexer.write-new-cache-namespace` (set to False default), and if it's True, write to the new cache schema along with the old cache schema. **Previous change in this stack PR** #58178
This PR
namespace
parameters to themake_cache_key
function, and depending on the feature flag (set to false right now) will create cache keys from the new namespaces that are separate for the read path and write path.Next change in this stack PR
#58414
Motivation
Click to expand
The indexer is making the following assumptions with Memcached:
bulk_record
(the indexer’s “write path”)It’s very easy to break 1 or 2 inadvertently. For example, we are inserting key/value pairs back into the cache during a
resolve
cache miss. Doing so is justified as some strings could be more read heavy than write heavy, such as users with automated scripts that are scanning for a specific key to show up.Background
Click to expand
How accessing the cache works today in the Indexer
- Emit
CACHE_READ
in header- Emit DB_READ in header
- Write {string} → {id} to cache
- Write {string} → {id} to cache
where
bulk_record
= the code path for writing indexed stringsand
resolve
= the code path for querying stringsGoal
Click to expand
We store a timestamp of when the cache is stored in the value, and also partition the key between the write and read path.(writer + string) → (integer + timestamp)
How this works
- Emit CACHE_READ in header
- Emit DB_READ in header
- Write br:{string} → {id}:{timestamp} to cache
- Increment metric
- Emit DB_READ in header
- Write br:{string} → {id}:{timestamp} to cache
- Write res:{string} → {id}:{timestamp} to cache
- Increment metric
- Write res:{string} → {id}:{timestamp} to cache
Deployment Plan
Click to expand
(string) → (integer)
and(writer + string) → (integer + timestamp)
via a sentry optionbulk_record
changes to write to both types of key/value pairs ((string) → (integer)
and(writer + string) → (integer + timestamp)
) on eachbulk_record
lookup(writer + string) → (integer + timestamp)
resolve
path cache replenishmentLocal Testing
Click to expand
Started sentry with memcache and kcat on
snuba-generic-metrics
Send first batch of 3 messages with the send_metrics script
Confirm that all 3 values have fetch type of FIRST_SEEN ("f")
Send the same batch of 3 messages with the send_metrics script
Confirm that the new messages all have fetch type of CACHE_HIT ("c")