Skip to content
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

fix: fix cache data may errors #2132

Merged
merged 1 commit into from
Apr 7, 2023

Conversation

KANLON
Copy link
Contributor

@KANLON KANLON commented Apr 2, 2023

Fix cache errors when there is column permission control, the same sql for different views, and the data source does not support paging sql

修复缓存数据可能错误的问题,当有下面的情况,缓存的数据可能是错误,因为的没有只是根据sql缓存

  1. 当有列权限控制 (目前列权限是根据不同角色控制的,如果view设置了缓存,那样所有人都会看到相同的缓存的,而不是根据设置的列权限,谁能看到不同权限数据)
  2. 不同数据源不同view相同sql (不同数据源 时候即使sql一样,数据也可能不一样,如果单单针对sql缓存了就会返回相同缓存数据)
  3. 数据源不支持分页sql的时候(目前在判断的分页到时候,会有两种情况数据源,一个是sql支持分页的,这种是会修改sql支持分页参数,这个时候对分页缓存是没问题的;另一种是sql不支持分页,代码中是通过Connection statement 实现的,这种情况下通过sql去缓存数据,会导致不同分页参数的请求都获取到同一个缓存数据,presto 数据源就是这样)

目前我改进的方法:在生成缓存key的时候,加上列权限字段列表,viewId和分页参数 ,这样就可以避免以上三种情况导致缓存错误。

麻烦帮忙code review 了,或看看是否有什么问题了

…l, the same sql for different views, or the data source does not support paging sql
@Zclhlmgqzc
Copy link
Contributor

针对提到的第一点列权限 我认为应该缓存一份完整的 然后在获取数据时再根据列权限进行过滤 列权限拼接在 key 上 各种各样的排列组合可能会导致同一条 sql 缓存很多重复的数据 折中的办法应该存一份完整的

@scottsut scottsut requested a review from tianlu-root April 3, 2023 10:03
@tianlu-root tianlu-root merged commit 4876190 into running-elephant:dev Apr 7, 2023
@scottsut
Copy link
Contributor

感谢参与贡献!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants