songxiaosheng commented on issue #2190:
URL:
https://github.com/apache/shardingsphere-elasticjob/issues/2190#issuecomment-1463591169
> > Why there is no sharding information "sharding item for job"? There may
be the following situations: You can refer to the following code:
jobFacade.getShardingContexts();
> > ```
> > public ShardingContexts getShardingContexts() {
> > boolean isFailover = configService.load(true).isFailover();
> > if (isFailover) {
> > List<Integer> failoverShardingItems =
failoverService.getLocalFailoverItems();
> > if (!failoverShardingItems.isEmpty()) {
> > return
executionContextService.getJobShardingContext(failoverShardingItems);
> > }
> > }
> > shardingService.shardingIfNecessary();
> > List<Integer> shardingItems =
shardingService.getLocalShardingItems();
> > if (isFailover) {
> >
shardingItems.removeAll(failoverService.getLocalTakeOffItems());
> > }
> >
shardingItems.removeAll(executionService.getDisabledItems(shardingItems));
> > return
executionContextService.getJobShardingContext(shardingItems);
> > }
> > ```
>
>
因为进去发现是从缓存中获取,按照我的理解,这个缓存是通过Listener监听刷新的,那就有可能刚分片完,还没有刷新缓存的时候代码就执行到这里了,所以获取的是错误的缓存数据,导致sharding/0/instanceId和当前实例不同
do you find the log "sharding begin." , Two methods of shardingIfNecessary
method and getShardingContexts are in single thread
--
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]