michael-s-molina opened a new pull request #18576: URL: https://github.com/apache/superset/pull/18576
### SUMMARY When opening a dashboard or a chart in Explore, the URL will update with a new state key every time the page is reloaded even when the state isn't updated. This may not be scalable in high-traffic Superset deployments where it can quickly fill up disk space or exhaust the number of cache keys too fast, due to memory restrictions, making it more likely that a link you shared with someone a while ago becomes invalid. To address this problem we should consider the request context such as user ID, resource ID, etc, to generate new keys only if the context changes. This way we can reuse existing keys but at the same time maintain the uniqueness of storage spaces for different users/dashboards/datasets/charts. We could use HMAC to generate the same key for the same context but that would require key rotation management. We can’t base key generation on previous keys because we have POST scenarios where the key is not present. One example would be when the user is inside a dashboard and selects “View chart in Explore”. We can’t change the structure of the cache key to use the user and resource because this information is not present in the GET/DELETE requests and it would also require keeping backward compatibility with previous versions. To implement the desired behavior we’ll keep a secondary mapping of user and resources with the previously generated keys. We'll store this mapping together with the entry so they’ll share the same expiration time. We’ll also keep it in sync with DELETE events. That way we can reuse the keys and keep the solution backward compatible. Hat tip to @zhaoyongjie and @ktmud for bringing this concern during the reviews 👏🏼 ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF https://user-images.githubusercontent.com/70410625/152404373-a9680644-402c-4e48-a155-b47881f13993.mov ### TESTING INSTRUCTIONS 1 - Check that `form_data_key` is reused when the same user is accessing the same resource (dashboard or chart) 2 - Check that `form_data_key` changes with the user, dashboard, dataset, or chart changes. 3 - Check that the values associated with a given key are correctly retrieved from the server ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
