FrancescoCastaldi commented on code in PR #45895:
URL: https://github.com/apache/superset/pull/45895#discussion_r4433699215


##########
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:
   Resolved in commit 5b2e270487.
   
   Updated the user cache partition key to use `exec_context.principal_id` 
rather than `exec_context.identity_digest`. As noted, keying on `principal_id` 
decouples the user cache partition from `SECRET_KEY`, ensuring that cache 
entries remain valid and shared across web/worker nodes during rolling key 
rotations and upholding the contract pinned in 
`test_metadata_aliases_share_result_cache`.
   
   We also extended unit test coverage in 
`tests/unit_tests/semantic_layers/models_test.py` to assert exact 
`principal_id` keys (`("semantic-user", "1")`) and verify that rotating 
`current_app.config["SECRET_KEY"]` leaves the user's cache keys unchanged.



-- 
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]

  • [PR] fix(se... via GitHub
    • Re: [P... via GitHub
    • Re: [P... via GitHub
    • Re: [P... via GitHub
    • Re: [P... via GitHub
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... FrancescoCastaldi (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications
    • Re: [P... FrancescoCastaldi (via GitHub) via notifications
    • Re: [P... FrancescoCastaldi (via GitHub) via notifications
    • Re: [P... FrancescoCastaldi (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... EnxDev (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications

Reply via email to