You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "MrLiuFang (via GitHub)" <gi...@apache.org> on 2023/08/03 08:15:21 UTC
[GitHub] [dubbo] MrLiuFang opened a new issue, #12836: 关于@Cacheable的bug
MrLiuFang opened a new issue, #12836:
URL: https://github.com/apache/dubbo/issues/12836
### Environment
* Dubbo version: 3.2.4
* Operating System version: ubuntu
* Java version: 17
* spring boot 3.1.2
### Steps to reproduce this issue
在interface 上使用@Cacheable (org.springframework.cache.annotation.Cacheable)的问题
**生产者 interface:**
```
@Cacheable(value = FileDefinition.CACHE_KEY_URL_MULTIPLE,key = "#tableId + '-' + #fileFieldName + '-' +#tableName")
public Map<Long,String> getUrl(@NotNull Long tableId,@NotBlank String fileFieldName,@NotBlank String tableName);
```
**消费者调用方:**
```
fileExposeService.getUrlSingle(1L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
fileExposeService.getUrlSingle(2L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
fileExposeService.getUrlSingle(3L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
```
**在redis中缓存的数据如下:`(只有第一次远程调用可以正常缓存数据,第二,三次远程调用后的均无法正常缓存数据)`**

```
第一次远程调用能产生redis key为:(urlSingle::1-t_user-profilePhoto) 的缓存
fileExposeService.getUrlSingle(1L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
第二,三次远程调用均产生了错误的redis key为:(urlSingle::null-null-null) 的缓存
fileExposeService.getUrlSingle(2L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
fileExposeService.getUrlSingle(3L, UserPo.TABLE_NAME, UserDefinition.PROFILE_PHOTO_FIELD_NAME);
第二,三次远程调用产生的redis key 应为:(urlSingle::2-t_user-profilePhoto) (urlSingle::3-t_user-profilePhoto)
```
--
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: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670959361
> 使用这种方式是可以的
那就很奇怪了呀,你的缓存是在 client 侧还是 provider 侧的
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670959931
在 provider 侧的话 Dubbo 一直是直接调的 Spring 的 aop 代理的
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] 关于@Cacheable的bug [dubbo]
Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1871111819
@MrLiuFang
Is there any progress?
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] 关于@Cacheable的bug [dubbo]
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ closed issue #12836: 关于@Cacheable的bug
URL: https://github.com/apache/dubbo/issues/12836
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670882570
> 非常迷惑的是同一个方法体里第一次远程调用可以正常缓存。 第二次,第三次,第……次就不行了!!
在外面套一层 proxy,然后打个日志看看呢
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] MrLiuFang commented on issue #12836: 关于@Cacheable的bug
Posted by "MrLiuFang (via GitHub)" <gi...@apache.org>.
MrLiuFang commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670927793
> Dubbo -> proxy -> cache
**使用这种方式是可以的
把@Cacheable 放到@DubboService但是就失去了缓存的意义了, 需要走一次RPC调用, 这个过程比较耗时。
想把cache放在interface, 消费端引用interface, 直接在消费端走缓存减少RPC的调用耗时**
```
@DubboService(interfaceClass = FileExposeService.class)
public class FileExposeServiceImpl implements FileExposeService {
@Override
@Cacheable(value = FileDefinition.CACHE_KEY_URL_MULTIPLE,key = "#tableId + '-' + #fileFieldName + '-' +#tableName")
public Map<Long, String> getUrl(Long tableId, String fileFieldName,String tableName) {
…………
return urls;
}
@Override
@Cacheable(value = FileDefinition.CACHE_KEY_URL_MULTIPLE,key = "#tableId + '-' + #fileFieldName + '-' +#tableName")
public String getUrlSingle(Long tableId, String fileFieldName, String tableName) {
…………
return "";
}
```
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] MrLiuFang commented on issue #12836: 关于@Cacheable的bug
Posted by "MrLiuFang (via GitHub)" <gi...@apache.org>.
MrLiuFang commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670796320
非常迷惑的是第一次远程调用可以正常缓存。 第二次,第三次,第……次就不行了!!
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670791524
Dubbo 是直接调用代理对象的,这个需要看下是不是 Spring 那边返回有差异
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] zhanghailang123 commented on issue #12836: 关于@Cacheable的bug
Posted by "zhanghailang123 (via GitHub)" <gi...@apache.org>.
zhanghailang123 commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1665621074
我觉得@Cacheable底层实现是
Spring动态代理,而Dubbo基于远程实现的代理对象是不是不兼容?
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] MrLiuFang commented on issue #12836: 关于@Cacheable的bug
Posted by "MrLiuFang (via GitHub)" <gi...@apache.org>.
MrLiuFang commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670973661
> > 使用这种方式是可以的
>
> 那就很奇怪了呀,你的缓存是在 client 侧还是 provider 侧的
目前是放client侧
放provider侧没问题,同一个方法体里多次调用都能正常缓存数据。
放client侧就有问题,同一个方法体里多次rpc远程调用除了第一次远程rpc调用能正常缓存数据,其它的第二,三次……都不能正常缓存数据。
其实无论放provider还是client方案设计上都没问题, 主要是想把@Cacheable放到interface接口上,就变成了client侧,从而减少dubbo rpc远程调用的耗时,但是这种做法就会导致上诉问题
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] 关于@Cacheable的bug [dubbo]
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1987577937
No news is good news. Please feel free to create a new issue if you have any question.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670882983
Dubbo -> proxy -> cache
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] MrLiuFang commented on issue #12836: 关于@Cacheable的bug
Posted by "MrLiuFang (via GitHub)" <gi...@apache.org>.
MrLiuFang commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670983914
> 放在 client 侧的话是不是第二次调用都没进dubbo……
这个有可能,我debug下看看
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] AlbumenJ commented on issue #12836: 关于@Cacheable的bug
Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ commented on issue #12836:
URL: https://github.com/apache/dubbo/issues/12836#issuecomment-1670980670
放在 client 侧的话是不是第二次调用都没进dubbo……
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org