dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Sync spring init actions to prevent parallel init

Open AlbumenJ opened this issue 1 year ago • 3 comments

What is the purpose of the change

Status: Dubbo not inited. Early trigger Dubbo invoke during Spring Application Listener init.

main thread: invoke Dubbo Reference Bean -> referenceConfig not prepared ->                                  success get not well prepared referenceConfig -> invoke -> throw config not found exception
other thread: invoke Dubbo Reference Bean -> referenceConfig not prepared -> trigger spring config listener config load -> still getting config
stack=java.lang.IllegalStateException: No application config found or it's not a valid config! Please add <dubbo:application name="..." /> to your spring config.
  at org.apache.dubbo.config.utils.ConfigValidationUtils.validateApplicationConfig(ConfigValidationUtils.java:494)
  at org.apache.dubbo.config.utils.DefaultConfigValidator.validate(DefaultConfigValidator.java:48)
  at org.apache.dubbo.config.context.AbstractConfigManager.checkDefaultAndValidateConfigs(AbstractConfigManager.java:620)
  at org.apache.dubbo.config.context.ConfigManager.checkConfigs(ConfigManager.java:302)
  at org.apache.dubbo.config.context.ConfigManager.loadConfigs(ConfigManager.java:282)
  at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.loadApplicationConfigs(DefaultApplicationDeployer.java:255)
  at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.initialize(DefaultApplicationDeployer.java:222)
  at org.apache.dubbo.config.deploy.DefaultModuleDeployer.prepare(DefaultModuleDeployer.java:638)
  at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:232)
  at org.apache.dubbo.config.ReferenceConfigBase.get(ReferenceConfigBase.java:395)
  at org.apache.dubbo.config.spring.ReferenceBean.getCallProxy(ReferenceBean.java:446)
  at org.apache.dubbo.config.spring.ReferenceBean.access$100(ReferenceBean.java:108)
  at org.apache.dubbo.config.spring.ReferenceBean$DubboReferenceLazyInitTargetSource.getTarget(ReferenceBean.java:453)
  at org.apache.dubbo.config.spring.util.LazyTargetInvocationHandler.invoke(LazyTargetInvocationHandler.java:50)

Brief changelog

Verifying this change

Checklist

  • [x] Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • [ ] Each commit in the pull request should have a meaningful subject line and body.
  • [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • [ ] Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • [ ] Add some description to dubbo-website project if you are requesting to add a feature.
  • [ ] GitHub Actions works fine on your own branch.
  • [ ] If this contribution is large, please follow the Software Donation Guide.

AlbumenJ avatar Jun 26 '24 03:06 AlbumenJ

@CrazyHZM PTAL

AlbumenJ avatar Jun 27 '24 05:06 AlbumenJ

I think the user‘s listener should have a lower priority than Dubbo. Ensure that the Dubbo status is initialized.

CrazyHZM avatar Jun 27 '24 13:06 CrazyHZM