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

Column index out of range. #34084

Open
HADESCH9 opened this issue Dec 17, 2024 · 5 comments
Open

Column index out of range. #34084

HADESCH9 opened this issue Dec 17, 2024 · 5 comments

Comments

@HADESCH9
Copy link

HADESCH9 commented Dec 17, 2024

Bug Report

When integrating Seata with ShardingSphere-JDBC version 5.5.1, the following error occurred:

2024-12-17 10:04:50.627 ERROR   o.a.s.r.d.s.s.c.AbstractTableMetaCache:   71 lambda$getTableMeta$0 - get table meta of the table `vehicle_blacklist` error: Column index out of range. java.sql.SQLException: Column index out of range.
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.result.ResultSetMetaData.getField(ResultSetMetaData.java:221) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.result.ResultSetMetaData.isCaseSensitive(ResultSetMetaData.java:325) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSetMetaData.isCaseSensitive(ShardingSphereResultSetMetaData.java:61) ~[shardingsphere-jdbc-5.5.1.jar!/:5.5.1]
        at org.apache.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.resultSetMetaToSchema(MysqlTableMetaCache.java:147) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.fetchSchema(MysqlTableMetaCache.java:83) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.lambda$getTableMeta$0(AbstractTableMetaCache.java:69) ~[seata-all-2.2.0.jar!/:2.2.0]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2379) ~[caffeine-2.8.0.jar!/:?]
        at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1892) ~[?:1.8.0_241]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2377) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2360) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62) ~[caffeine-2.8.0.jar!/:?]
        at org.apache.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.getTableMeta(AbstractTableMetaCache.java:67) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:325) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.DeleteExecutor.beforeImage(DeleteExecutor.java:57) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitFalse(AbstractDMLBaseExecutor.java:98) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:85) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:127) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:168) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:63) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55) ~[seata-all-2.2.0.jar!/:2.2.0]
        at sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241]
        at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.2.jar!/:3.5.2]
        at com.sun.proxy.$Proxy291.execute(Unknown Source) ~[?:?]
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.2.jar!/:3.5.2]
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.2.jar!/:3.5.2]
        at sun.reflect.GeneratedMethodAccessor1120.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]

Which version of ShardingSphere did you use?

5.5.1

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Actual behavior

error

2024-12-17 10:04:50.627 ERROR   o.a.s.r.d.s.s.c.AbstractTableMetaCache:   71 lambda$getTableMeta$0 - get table meta of the table `vehicle_blacklist` error: Column index out of range. java.sql.SQLException: Column index out of range.
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.result.ResultSetMetaData.getField(ResultSetMetaData.java:221) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at com.mysql.cj.jdbc.result.ResultSetMetaData.isCaseSensitive(ResultSetMetaData.java:325) ~[mysql-connector-java-8.0.16.jar!/:8.0.16]
        at org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSetMetaData.isCaseSensitive(ShardingSphereResultSetMetaData.java:61) ~[shardingsphere-jdbc-5.5.1.jar!/:5.5.1]
        at org.apache.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.resultSetMetaToSchema(MysqlTableMetaCache.java:147) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.sql.struct.cache.MysqlTableMetaCache.fetchSchema(MysqlTableMetaCache.java:83) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.lambda$getTableMeta$0(AbstractTableMetaCache.java:69) ~[seata-all-2.2.0.jar!/:2.2.0]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2379) ~[caffeine-2.8.0.jar!/:?]
        at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1892) ~[?:1.8.0_241]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2377) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2360) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:108) ~[caffeine-2.8.0.jar!/:?]
        at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:62) ~[caffeine-2.8.0.jar!/:?]
        at org.apache.seata.rm.datasource.sql.struct.cache.AbstractTableMetaCache.getTableMeta(AbstractTableMetaCache.java:67) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.BaseTransactionalExecutor.getTableMeta(BaseTransactionalExecutor.java:325) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.DeleteExecutor.beforeImage(DeleteExecutor.java:57) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.AbstractDMLBaseExecutor.executeAutoCommitFalse(AbstractDMLBaseExecutor.java:98) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.AbstractDMLBaseExecutor.doExecute(AbstractDMLBaseExecutor.java:85) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.BaseTransactionalExecutor.execute(BaseTransactionalExecutor.java:127) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:168) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.exec.ExecuteTemplate.execute(ExecuteTemplate.java:63) ~[seata-all-2.2.0.jar!/:2.2.0]
        at org.apache.seata.rm.datasource.PreparedStatementProxy.execute(PreparedStatementProxy.java:55) ~[seata-all-2.2.0.jar!/:2.2.0]
        at sun.reflect.GeneratedMethodAccessor292.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241]
        at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.2.jar!/:3.5.2]
        at com.sun.proxy.$Proxy291.execute(Unknown Source) ~[?:?]
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.2.jar!/:3.5.2]
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.2.jar!/:3.5.2]
        at sun.reflect.GeneratedMethodAccessor1120.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]

Reason analyze (If you can)

I suspect that the issue arises from the "like" column configured for fuzzy search in the table.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).

@strongduanmu
Copy link
Member

@HADESCH9 Can you modify this issue according to issue template?

@HADESCH9
Copy link
Author

@HADESCH9 Can you modify this issue according to issue template?

ok

@terrymanu
Copy link
Member

What is your SQL and configuration?

@HADESCH9
Copy link
Author

Field mapping configuration file is as follows

rules:
  - !SINGLE
    tables:
      - "ds1.*"
  - !ENCRYPT
    tables:
      vehicle_blacklist:
        columns:
          license_plate_number:
            name: license_plate_number
            cipher:
              name: license_plate_number_cipher
              encryptorName: aes_encryptor
            likeQuery:
              name: license_plate_number_cipher_col
              encryptorName: like_queyr_encryptor

Error occurred before and after updating the SQL, when Seata tried to retrieve the data before the update, an error was reported

Error content as follows
image

@terrymanu
Copy link
Member

What is the database configuration and SQL details and table metadata?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants