apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.94k stars 6.74k forks source link

sharding-jdbc integration seata Java.sqlexception: Failed to fetch schema of stock #24042

Closed mbql closed 4 months ago

mbql commented 1 year ago

environment: jdk8 seata 1.6.1 sharding-jdbc 5.2.1

Question: Microservice using seata distributed transaction, call with the following error: java.sql.SQLException: Failed to fetch schema of stock at io.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.fetchSchema(MysqlTableMetaCache.java:87) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.lambda$getTableMeta$0(AbstractTableMetaCache.java:61) ~[seata-all-1.6.1.jar:1.6.1] at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2406) ~[caffeine-2.9.3.jar:na] at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853) ~[na:1.8.0_141] at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2404) ~[caffeine-2.9.3.jar:na] at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2387) ~[caffeine-2.9.3.jar:na] at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108) ~[caffeine-2.9.3.jar:na] at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62) ~[caffeine-2.9.3.jar:na] at io.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.getTableMeta(AbstractTableMetaCache.java:59) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:310) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:295) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.UpdateExecutor.beforeImage(UpdateExecutor.java:70) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitFalse(AbstractDMLBaseExecutor.java:96) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:84) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:125) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:137) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:56) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55) ~[seata-all-1.6.1.jar:1.6.1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy138.execute(Unknown Source) ~[na:na] at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy137.update(Unknown Source) ~[na:na] at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) ~[mybatis-3.5.10.jar:3.5.10] at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106) ~[mybatis-plus-extension-3.5.3.1.jar:3.5.3.1] at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy136.update(Unknown Source) ~[na:na] at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.7.jar:2.0.7] at com.sun.proxy.$Proxy129.update(Unknown Source) ~[na:na] at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288) ~[mybatis-spring-2.0.7.jar:2.0.7] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:64) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.sun.proxy.$Proxy130.subGoodsStockByGoodNo(Unknown Source) ~[na:na] at com.sueno.shop.stock.remote.RemoteStockServiceImpl.subGoodsStockByGoodNo(RemoteStockServiceImpl.java:27) ~[classes/:na] at com.sueno.shop.stock.remote.RemoteStockServiceImpl$$FastClassBySpringCGLIB$$82003c54.invoke() ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.22.jar:5.3.22] at com.sueno.shop.stock.remote.RemoteStockServiceImpl$$EnhancerBySpringCGLIB$$57a30a71.subGoodsStockByGoodNo() ~[classes/:na] at com.sueno.shop.stock.api.service.RemoteStockServiceDubboWrap0.invokeMethod(RemoteStockServiceDubboWrap0.java) ~[dubbo-3.2.0-beta.3.jar:na] at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:73) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:100) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:55) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ClassLoaderCallbackFilter.invoke(ClassLoaderCallbackFilter.java:38) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at com.alibaba.dubbo.rpc.Invoker$CompatibleInvoker.invoke(Invoker.java:55) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at io.seata.integration.dubbo.alibaba.AlibabaDubboTransactionPropagationFilter.invoke(AlibabaDubboTransactionPropagationFilter.java:45) ~[seata-all-1.6.1.jar:1.6.1] at com.alibaba.dubbo.rpc.Filter.invoke(Filter.java:29) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:79) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:45) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.seata.SeataTransactionPropagationProviderFilter.invoke(SeataTransactionPropagationProviderFilter.java:66) ~[dubbo-filter-seata-1.0.0.jar:1.0.0] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:100) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:54) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.metrics.filter.MetricsFilter.invoke(MetricsFilter.java:51) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:192) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:54) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ProfilerServerFilter.invoke(ProfilerServerFilter.java:63) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:143) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:194) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:156) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:103) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:186) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:53) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:61) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_141] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_141] at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_141] Caused by: io.seata.common.exception.ShouldNeverHappenException: Could not found any index in the table: stock at io.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.resultSetMetaToSchema(MysqlTableMetaCache.java:182) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.fetchSchema(MysqlTableMetaCache.java:83) ~[seata-all-1.6.1.jar:1.6.1] ... 110 common frames omitted

Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1615112] Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1615112] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1615112] 2023-02-04 20:09:01.262 ERROR 6588 --- [:20881-thread-4] o.a.dubbo.rpc.filter.ExceptionFilter : [DUBBO] Got unchecked and undeclared exception which called by 192.168.101.1. service: com.sueno.shop.stock.api.service.RemoteStockService, method: subGoodsStockByGoodNo, exception: org.springframework.jdbc.UncategorizedSQLException:

Error updating database. Cause: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. The error may exist in file [E:\项目\sueno-shop\sueno-shop-stock\sueno-shop-stock-service\target\classes\mapper\StockMapper.xml] The error may involve defaultParameterMap The error occurred while setting parameters SQL: update stock set stock_num = stock_num - ? where good_no = ? and stock_num > 0 Cause: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. ; uncategorized SQLException; SQL state [null]; error code [0]; io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists.; nested exception is java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists., dubbo version: 3.2.0-beta.3, current host: 192.168.101.1, error code: 5-36. This may be caused by , go to https://dubbo.apache.org/faq/5/36 to find instructions.

org.springframework.jdbc.UncategorizedSQLException:

Error updating database. Cause: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. The error may exist in file [E:\项目\sueno-shop\sueno-shop-stock\sueno-shop-stock-service\target\classes\mapper\StockMapper.xml] The error may involve defaultParameterMap The error occurred while setting parameters SQL: update stock set stock_num = stock_num - ? where good_no = ? and stock_num > 0 Cause: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. ; uncategorized SQLException; SQL state [null]; error code [0]; io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists.; nested exception is java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92) ~[mybatis-spring-2.0.7.jar:2.0.7] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) ~[mybatis-spring-2.0.7.jar:2.0.7] at com.sun.proxy.$Proxy129.update(Unknown Source) ~[na:na] at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288) ~[mybatis-spring-2.0.7.jar:2.0.7] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:64) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.3.1.jar:3.5.3.1] at com.sun.proxy.$Proxy130.subGoodsStockByGoodNo(Unknown Source) ~[na:na] at com.sueno.shop.stock.remote.RemoteStockServiceImpl.subGoodsStockByGoodNo(RemoteStockServiceImpl.java:27) ~[classes/:na] at com.sueno.shop.stock.remote.RemoteStockServiceImpl$$FastClassBySpringCGLIB$$82003c54.invoke() ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.22.jar:5.3.22] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.22.jar:5.3.22] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.22.jar:5.3.22] at com.sueno.shop.stock.remote.RemoteStockServiceImpl$$EnhancerBySpringCGLIB$$57a30a71.subGoodsStockByGoodNo() ~[classes/:na] at com.sueno.shop.stock.api.service.RemoteStockServiceDubboWrap0.invokeMethod(RemoteStockServiceDubboWrap0.java) ~[dubbo-3.2.0-beta.3.jar:na] at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:73) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:100) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:55) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ClassLoaderCallbackFilter.invoke(ClassLoaderCallbackFilter.java:38) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at com.alibaba.dubbo.rpc.Invoker$CompatibleInvoker.invoke(Invoker.java:55) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at io.seata.integration.dubbo.alibaba.AlibabaDubboTransactionPropagationFilter.invoke(AlibabaDubboTransactionPropagationFilter.java:45) ~[seata-all-1.6.1.jar:1.6.1] at com.alibaba.dubbo.rpc.Filter.invoke(Filter.java:29) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:79) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:45) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.seata.SeataTransactionPropagationProviderFilter.invoke(SeataTransactionPropagationProviderFilter.java:66) ~[dubbo-filter-seata-1.0.0.jar:1.0.0] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:100) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:54) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.metrics.filter.MetricsFilter.invoke(MetricsFilter.java:51) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:192) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:54) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ProfilerServerFilter.invoke(ProfilerServerFilter.java:63) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:143) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:194) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:156) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:103) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:186) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:53) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:61) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_141] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_141] at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41) ~[dubbo-3.2.0-beta.3.jar:3.2.0-beta.3] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_141] Caused by: java.sql.SQLException: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:141) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:56) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55) ~[seata-all-1.6.1.jar:1.6.1] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy138.execute(Unknown Source) ~[na:na] at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy137.update(Unknown Source) ~[na:na] at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.10.jar:3.5.10] at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) ~[mybatis-3.5.10.jar:3.5.10] at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106) ~[mybatis-plus-extension-3.5.3.1.jar:3.5.3.1] at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) ~[mybatis-3.5.10.jar:3.5.10] at com.sun.proxy.$Proxy136.update(Unknown Source) ~[na:na] at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194) ~[mybatis-3.5.10.jar:3.5.10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.7.jar:2.0.7] ... 62 common frames omitted Caused by: io.seata.common.exception.ShouldNeverHappenException: [xid:192.168.31.128:8092:27378202007797761]get table meta failed, please check whether the table stock exists. at io.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.getTableMeta(AbstractTableMetaCache.java:69) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:310) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:295) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.UpdateExecutor.beforeImage(UpdateExecutor.java:70) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitFalse(AbstractDMLBaseExecutor.java:96) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:84) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:125) ~[seata-all-1.6.1.jar:1.6.1] at io.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:137) ~[seata-all-1.6.1.jar:1.6.1] ... 95 common frames omitted

Implementation scheme: sharding-jdbc: database and table separation + read/write separation

Check the cause: The table name obtained from the resultSetMetaToSchema() method called in the fetchSchema() method of seata framework is a logical table name, but not a real table name. The core of the call process is as follows: The resultSetMetaToSchema method --> getIndexInfo method

image

Eventually getIndexInfo() in the DatabaseMetaData class is called to look up the index information for the table. The data obtained here is empty because the logical table name is used, not the real one

image

Previously, because the fetch index result was null, the exception was thrown all the way up to getTableMeta(), as follows:

image

Continue tracking rsmd.getTableName(1) in the resultSetMetaToSchema() method; The fetch table name is a logical table name, not a real table name

image

Then call ShardingSphereResultSetMetaData class getTableName () method

image

Finally, in a class call ShardingRule findLogicTableByActualTable () method

image

RaigorJiang commented 1 year ago

Looks like a complicated scenario, can you provide a demo to reproduce this problem?

mbql commented 1 year ago

Looks like a complicated scenario, can you provide a demo to reproduce this problem?

Yes, first of all, this scenario is based on the micro-service architecture. Each service is divided into database and table and read-write separation. Components: seata version 1.6.1, shardingsphere version 5.2.1, dubbo version 3.2.0-beta.3, mybatis-plus version 3.5.3.1. I made a common e-shopping scene here. Three services, commodity service, inventory service and order service, were started, and the remote call was made through remote dubbo rpc. When the order was requested, the error mentioned above occurred when the inventory service was called to deduct the inventory, that is, the logical database did not exist, because the sharding was done here, the logical library should be resolved into the real library. This does not result in an error for the underlying jdbc operations. However, this is not the case. See the previous description for the debugging results. Repeat scenario: This problem may occur when both the caller and the called party divide libraries and tables. Demo is also provided here for testing. The Demo is reproduced as follows: sueno-shop.zip

terrymanu commented 4 months ago

I don't think "library" is a concept related to ShardingSphere. Due to the high cost of understanding, please allow me to close this issue.