EnxDev commented on code in PR #45895:
URL: https://github.com/apache/superset/pull/45895#discussion_r4431282083
##########
superset/semantic_layers/models.py:
##########
@@ -905,6 +905,25 @@ def get_extra_cache_keys(self, query_obj: QueryObjectDict)
-> list[Hashable]:
keys: list[Hashable] = [self.metadata_generation,
"semantic-null-filters-v1"]
if discriminator is not None:
keys.append(("semantic-result-version", *discriminator))
+
+ from superset import is_feature_enabled
+
+ if is_feature_enabled("CACHE_QUERY_BY_USER"):
+ try:
+ from superset.semantic_layers.execution import (
+ current_host_execution_context,
+ )
+
+ exec_context = current_host_execution_context()
+ if not exec_context.is_guest and exec_context.identity_digest:
+ keys.append(("semantic-user",
exec_context.identity_digest))
Review Comment:
`identity_digest` is an HMAC keyed with `SECRET_KEY`, so with the flag on a
key rotation changes every user's cache key. That breaks what
`test_metadata_aliases_share_result_cache` pins (a worker-cached result stays
readable after `SECRET_KEY` changes), and mid-rotation web and workers keep
missing each other's results.
Keying on `principal_id` avoids it. Heads up that #45900 fixes the same
issue that way, so it's probably worth settling on one of the two.
```suggestion
if not exec_context.is_guest and exec_context.principal_id:
keys.append(("semantic-user", exec_context.principal_id))
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]