FAQ and solutions for the MSHA SDK.

更新时间:
复制 MD 格式

This topic describes common questions and provides solutions for the MSHA SDK.

Where are the MSHA SDK log files?

The MSHA SDK log files are in the ~/logs/msha/sdk.$appName/ and ~/logs/msha/bridge.$appName/ directories.

The MSHA SDK log directories are shown in the following figures:

image

image

image

Pay close attention to the following log files:

  • sdk.log: SDK startup logs, including logs for pulling global routing rules and data layer MySQL logs.

  • sdk_error.log: Exception logs for the base SDK package.

  • bridge.log: Startup logs for the SDK module package. This is where logs for separately imported `msha-bridge-xxx` packages are printed.

  • bridge_error.log: Exception logs for the SDK module package.

Where is the configuration information for the MSHA SDK?

  1. Multi-active instance configurations are pushed to the namespace that corresponds to the control command channel of the multi-active instance configuration. After the baseline takes effect, you can view the pushed information in the configuration list.

  2. MSHA SDK configuration directory: ~/nacos/config/fixed-$nacosAddress_8848-$nacosNamespace_nacos/snapshot-tenant/$nacosNamespace/MSHA_GROUP/

The MSHA SDK configuration directory is shown in the following figure. The file list in this directory must be consistent with the one in the control command channel.

image

  1. Directory for MSHA SDK configuration pull logs: ~/logs/nacos/config.log

image

After integrating the MSHA SDK, how do I check if it is working?

  1. Check if the SDK is working: Check whether the MSHA SDK log directory is generated locally.

    1. Not generated: The SDK is not working.

    2. Generated: Check the sdk.log file. If initialization logs such as init msha Default SDK Service Factory are printed, the SDK is working.

  2. Check if the data layer module is working: After triggering a database read or write operation, check the MSHA SDK logs for initialization information.

    1. MySQL data source: Check the sdk.log file. If keywords such as Driver::connect or MshaConnection are printed, the SDK is working.

    2. Other data sources: Check the bridge.log file. Search for the host of the data source. If related logs are printed, the SDK is working.

  3. Check if the service layer module is working: After triggering a service invocation, capture packets to check the service discovery status.

    1. Install Arthas on the consumer. Run: curl -O https://arthas.aliyun.com/arthas-boot.jar

    2. After selecting the process, run watch com.aliyun.msha.bridge.rpc.base.unitcell.impl.RPCUnitCellMshaService getFilterResult "{params,returnObj,throwExp}" -x 3 '1==1'

    3. Make a service call without passing a routing tag. The server list captured by Arthas is empty.

    4. Make a service call with a routing tag. The server list captured by Arthas contains addresses.

  4. Check if the message layer module is working: Send a cross-unit message and check the MSHA SDK logs.

    1. Check the sdk_mq_standard.log file. Results for cross-unit messages, exception messages, and more are printed in this file.

The database module is not enabled. Please enable the module

  1. Cause: The MSHA SDK failed to read the database module information.

    1. The MySQL module is not enabled for the multi-active instance that corresponds to the -Dmsha.namespaces startup parameter.

    2. The module is enabled for the multi-active instance, but the MSHA SDK failed to read the configuration.

  2. Resolution:

    1. Check the multi-active instance, enable the MySQL module, and click Apply Baseline. After the baseline is applied, restart the application.

    2. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.router.control.metadata configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Click Apply Baseline. After the baseline is applied, restart the application.

        2. Exists: Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

      2. Pulled: Open the file and view its content.

        1. Unencrypted content: Check if the MySQL module is included.

        2. Encrypted content: Copy the content and the multi-active instance ID, and then contact us to check the configuration.

    3. If none of the preceding steps resolve the issue: Check the sdk_error.log file for ERROR logs. Contact us and provide the logs.

Can't find unit by local region[xxx] and zone xxx

  1. Cause: The MSHA SDK failed to read the LDC information.

    1. The configuration information was not pulled locally.

    2. For ACK or local deployments, the region information cannot be automatically obtained.

  2. Solution:

    1. Manually add the -Dregion-id and -Dzone-id startup parameters. Set region-id to the local region, such as `cn-beijing`. You can select any value for zone-id, such as `cn-beijing-a`.

    2. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.router.control.metadata configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Click Apply Baseline. After the baseline is applied, restart the application.

        2. Exists: Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

get demotion metadata fail, caused by null xxx with metadata

  1. Cause: The MSHA SDK failed to read the data source information.

    1. The configuration information was not pulled locally.

  2. Solution:

    1. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.$dataSourceType_attribute.$dataSourceIdentifier(including host, port, instance ID, etc.) configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Find the data protection rule to which the data source belongs and click Push Full Rule. Wait until the status of the protection rule changes to Effective, and then trigger the database call again.

        2. Exists:

          1. Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

          2. Check the push identifier in the MSHA console, the data source URL in the application configuration file, and the configuration center filename. The host, port, db, and instance ID elements must be consistent across all three.

NoClassDefFoundError: Could not initialize class com.ali.unit.router.driver.Driver

  1. Cause: The MSHA SDK package was not imported.

    1. driver-class-name: com.ali.unit.router.driver.Driver is configured, but the msha-router-all package is not imported.

    2. The msha-router-all package is imported, but it does not take effect after deployment because of issues such as version conflicts.

  2. Solution:

    1. Import the msha-router-all package.

      <dependency>
        <groupId>com.aliyun.msha</groupId>
        <artifactId>msha-router-all</artifactId>
        <version>x.y.z</version>
      </dependency>
    2. In the post-deployment environment, run `jar -tf xxx.jar` to check if the com.ali.unit.router.driver.Driver class is included.

NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer

  1. Cause: cglib version conflict.

  2. Solution:

    1. Explicitly specify the cglib version. The MSHA SDK uses the following version:

      <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
      </dependency>
      Important

      You can exclude the cglib dependency of MSHA and specify the version required by your business. Alternatively, you can exclude the version your business depends on and use the version that MSHA depends on.

      • Note that cglib must be used with the asm package. The versions are mapped. For example, cglib 3.1 corresponds to asm 4.2.

reporter client metaData failed,please check reporter-remote-ip connectedness

  1. Cause: The MSHA SDK cannot report monitoring metrics to the MSHA backend.

  2. Solution:

    1. Check the sdk_report.log file to identify the cause of the connection failure. It is usually a network issue.

    2. For local deployments, it is normal for the metric reporting connection to fail. You can ignore this error.

    3. This error does not affect business logic. It only prevents you from viewing monitoring charts in the MSHA console.

ClassNotFoundException: com.oceanbase.jdbc.Driver

This error is normal. When you use a MySQL data source, the MSHA SDK searches for several specific drivers in sequence as a fallback mechanism. This error is printed only once during startup and can be ignored.

No pool class find

  1. Cause: Jedis module initialization failed.

  2. Solution: Check the dependencies. One of the following two classes must exist: redis.clients.util.Pool or redis.clients.jedis.util.Pool.

get tenant encrypt key error null

  1. Cause: The MSHA SDK failed to read the configuration file.

  2. Solution:

    1. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.router.control.global.define configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Click Apply Baseline. After the baseline is applied, restart the application.

        2. Exists: Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

No redis active unit instance found

  1. Cause: The MSHA SDK failed to read the current central unit information.

    1. The configuration information was not pulled locally.

  2. Solution:

    1. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.router.control.metadata configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Click Apply Baseline. After the baseline is applied, restart the application.

        2. Exists: Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

Write fail, It's under delay and the dts delay strategy is forbidden write

This error is normal. It occurs because Forbid Write is configured for the data protection rule and a traffic switchover is in progress. This triggers the write-blocking interception of the MSHA SDK.

What should I do if the database does not switch to the secondary database after a traffic switchover?

  1. Cause: The MSHA SDK is not working, or it failed to read the data source information.

    1. The SDK is not working. Read and write operations on the primary database do not pass through the SDK.

    2. The data source configuration was not pulled locally.

  2. Solution:

    1. Check the switchover order in the MSHA console to see if any nodes have errors.

    2. Check the local MSHA SDK configuration directory. For more information, see Where is the configuration information for the MSHA SDK?. Check if the com.ali.unit.$dataSourceType_attribute.$dataSourceIdentifier(including host, port, instance ID, etc.) configuration is pulled.

      1. Not pulled: Check if the file exists in the namespace that corresponds to the -Dmsha.nacos.server.addr startup parameter.

        1. Does not exist: Confirm that the -Dmsha.nacos.server.addr startup parameter is consistent with the control command channel configuration of the multi-active instance. Find the data protection rule to which the data source belongs and click Push Full Rule. Wait until the status of the protection rule changes to Effective, and then trigger the database call again.

        2. Exists:

          1. Check the ~/logs/nacos/config.log file. The local machine usually fails to connect to the Remote Configuration center because of network or authentication issues.

          2. Check the push identifier in the MSHA console, the data source URL in the application configuration file, and the configuration center filename. The host, port, db, and instance ID elements must be consistent across all three.

    3. Check the MSHA SDK log files for error messages.