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

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

Open
zlp1992 opened this issue Apr 24, 2024 · 3 comments
Open

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

zlp1992 opened this issue Apr 24, 2024 · 3 comments
Labels
type: question Further information is requested

Comments

@zlp1992
Copy link

zlp1992 commented Apr 24, 2024

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 zlp1992 added the type: question Further information is requested label Apr 24, 2024
@zlp1992 zlp1992 changed the title why thre are two same selector when register a new client [BUG] why thre are two same selector when register a new client Apr 24, 2024
@Aias00
Copy link
Contributor

Aias00 commented Apr 25, 2024

version pls?

@zlp1992
Copy link
Author

zlp1992 commented Apr 25, 2024

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

@Aias00
Copy link
Contributor

Aias00 commented Apr 26, 2024

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. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants