shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] why thre are two same selector when register a new client

Open zlp1992 opened this issue 1 year ago • 3 comments

Bug

when i register a new client,there are two same selector data image and in database, there are two records image after debug, i find if using nacos as registration center, and deploy more than one admin instance(for example two). when i start a client and to register, both admin server receive nacos change event and start to register meta data as follow: org.apache.shenyu.admin.service.impl.SelectorServiceImpl#registerDefault(org.apache.shenyu.register.common.dto.MetaDataRegisterDTO, java.lang.String, java.lang.String) below code, both admin instance with not find selectorDO and will create two same selector data

String contextPath = ContextPathUtils.buildContextPath(dto.getContextPath(), dto.getAppName());
        SelectorDO selectorDO = findByNameAndPluginName(contextPath, pluginName);
        if (Objects.isNull(selectorDO)) {
            SelectorDTO selectorDTO = SelectorUtil.buildSelectorDTO(contextPath, pluginMapper.selectByName(pluginName).getId());
            selectorDTO.setHandle(selectorHandler);
            return registerDefault(selectorDTO);
        }

that cause lot of warn AbstractRetryTask [shenyu-shared_wheel_timer-2] Failed to execute task:/o:divide,retried:1 ,total retries:-1,cause:nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

zlp1992 avatar Apr 24 '24 11:04 zlp1992

version pls?

Aias00 avatar Apr 25 '24 04:04 Aias00

version pls?

2.5.0,a little bit old, but i see the newest code org.apache.shenyu.admin.service.register.AbstractShenyuClientRegisterServiceImpl#register may has the same problem if more than one shenyu admin instance receive meta data register nacos change event at the same time

zlp1992 avatar Apr 25 '24 15:04 zlp1992

version pls?

2.5.0,a little bit old, but i see the newest code org.apache.shenyu.admin.service.register.AbstractShenyuClientRegisterServiceImpl#register may has the same problem if more than one shenyu admin instance receive meta data register nacos change event at the same time

hi, if u have time to handle this problem, u can make a pr to resolve it. 😊

Aias00 avatar Apr 26 '24 02:04 Aias00