taojintianxia opened a new issue #14739:
URL: https://github.com/apache/shardingsphere/issues/14739


   proxy commit id : 51ec973a056b3414f80b2d207f2236ac184f6a2e
   
   following is the step to reproduce the issue :
   1. downlod the shardingsphere code and checkout as the corresponding commit 
version
   2. compile the code and extract proxy distribution
   3. use the following config and then start proxy
   
   config-encrypt.yaml
   ```
   schemaName: encrypt_db
   
   dataSources:
     ds_0:
       url: 
jdbc:mysql://127.0.0.1:3306/encrypt_db?serverTimezone=UTC&useSSL=false
       username: root
       password:  
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 3000
       minPoolSize: 1
   
   rules:
   - !ENCRYPT
     encryptors:
       sm4_encryptor:
         type: SM4
         props:
           sm4-key: 123456ab
           sm4-mode: ECB
           sm4-padding: PKCS5Padding
       md5_encryptor:
         type: MD5
     tables:
       sbtest1:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest2:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest3:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest4:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest5:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest6:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest7:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest8:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest9:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
       sbtest10:
         columns:
           pad:
             cipherColumn: pad
             encryptorName: sm4_encryptor
     queryWithCipherColumn: true
   ```
   
   server.yaml
   ```
   rules:
     - !AUTHORITY
       users:
         - root@%:root
         - sharding@:sharding
       provider:
         type: ALL_PRIVILEGES_PERMITTED
   #  - !TRANSACTION
   #    defaultType: XA
   #    providerType: Atomikos
   #  - !SQL_PARSER
   #    sqlCommentParseEnabled: true
   #    sqlStatementCache:
   #      initialCapacity: 2000
   #      maximumSize: 65535
   #      concurrencyLevel: 4
   #    parseTreeCache:
   #      initialCapacity: 128
   #      maximumSize: 1024
   #      concurrencyLevel: 4
   
   props:
   #  max-connections-size-per-query: 1
   #  kernel-executor-size: 16  # Infinite by default.
   #  proxy-frontend-flush-threshold: 128  # The default value is 128.
   #  proxy-opentracing-enabled: false
   #  proxy-hint-enabled: false
   #  sql-show: false
   #  check-table-metadata-enabled: false
   #  show-process-list-enabled: false
   #    # Proxy backend query fetch size. A larger value may increase the 
memory usage of ShardingSphere Proxy.
   #    # The default value is -1, which means set the minimum value for 
different JDBC drivers.
   #  proxy-backend-query-fetch-size: -1
   #  check-duplicate-table-enabled: false
   #  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The 
default value is 0, which means let Netty decide.
   #    # Available options of proxy backend executor suitable: OLAP(default), 
OLTP. The OLTP option may reduce time cost of writing packets to client, but it 
may increase the latency of SQL execution
   #    # if client connections are more than 
proxy-frontend-netty-executor-size, especially executing slow SQL.
     proxy-backend-executor-suitable: OLTP
   #  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no 
limitation.
   #  sql-federation-enabled: false
   #    # Available proxy backend driver type: JDBC (default), ExperimentalVertx
   #  proxy-backend-driver-type: JDBC
   ```
   
   and then modify the sysbench oltp_common.lua, change the create table 
clause, make pad to char(200)
   start sysbench to test
   ```
   sysbench oltp_read_only --mysql-host=127.0.0.1 --mysql-port=3307 
--mysql-user=root --mysql-password='root' --mysql-db=encrypt_db --tables=10 
--table-size=1000000 --report-interval=10 --time=3600 --threads=10 
--max-requests=0 --percentile=99 --mysql-ignore-errors="all" 
--rand-type=uniform --range_selects=off --auto_inc=off cleanup
   sysbench oltp_read_only --mysql-host=127.0.0.1 --mysql-port=3307 
--mysql-user=root --mysql-password='root' --mysql-db=encrypt_db --tables=10 
--table-size=1000000 --report-interval=10 --time=3600 --threads=10 
--max-requests=0 --percentile=99 --mysql-ignore-errors="all" 
--rand-type=uniform --range_selects=off --auto_inc=off prepare
   
   sysbench oltp_point_select --mysql-host=127.0.0.1 --mysql-port=3307 
--mysql-user=root --mysql-password='root' --mysql-db=encrypt_db --tables=10 
--table-size=1000000 --report-interval=5 --time=300 --threads=64 
--max-requests=0 --percentile=99 --mysql-ignore-errors="all" 
--range_selects=off --rand-type=uniform --auto_inc=off run | tee 
oltp_point_select_64.txt
   
   ```
   
   and you will get the following problem :
   
   ```
   [ERROR] 2022-01-13 16:21:43.226 [epollEventLoopGroup-3-7] 
o.a.s.p.f.c.CommandExecutorTask - Exception occur:
   java.lang.IllegalStateException: Mode must be either CBC or ECB.
        at 
com.google.common.base.Preconditions.checkState(Preconditions.java:508)
        at 
org.apache.shardingsphere.encrypt.algorithm.SM4EncryptAlgorithm.checkAndGetMode(SM4EncryptAlgorithm.java:123)
        at 
org.apache.shardingsphere.encrypt.algorithm.SM4EncryptAlgorithm.sm4(SM4EncryptAlgorithm.java:103)
        at 
org.apache.shardingsphere.encrypt.algorithm.SM4EncryptAlgorithm.encrypt(SM4EncryptAlgorithm.java:76)
        at 
org.apache.shardingsphere.encrypt.algorithm.SM4EncryptAlgorithm.encrypt(SM4EncryptAlgorithm.java:72)
        at 
org.apache.shardingsphere.encrypt.algorithm.SM4EncryptAlgorithm.encrypt(SM4EncryptAlgorithm.java:40)
        at 
org.apache.shardingsphere.encrypt.rewrite.token.generator.impl.EncryptInsertValuesTokenGenerator.setCipherColumn(EncryptInsertValuesTokenGenerator.java:170)
        at 
org.apache.shardingsphere.encrypt.rewrite.token.generator.impl.EncryptInsertValuesTokenGenerator.encryptToken(EncryptInsertValuesTokenGenerator.java:128)
        at 
org.apache.shardingsphere.encrypt.rewrite.token.generator.impl.EncryptInsertValuesTokenGenerator.generateNewSQLToken(EncryptInsertValuesTokenGenerator.java:94)
        at 
org.apache.shardingsphere.encrypt.rewrite.token.generator.impl.EncryptInsertValuesTokenGenerator.generateSQLToken(EncryptInsertValuesTokenGenerator.java:67)
        at 
org.apache.shardingsphere.encrypt.rewrite.token.generator.impl.EncryptInsertValuesTokenGenerator.generateSQLToken(EncryptInsertValuesTokenGenerator.java:50)
        at 
org.apache.shardingsphere.infra.rewrite.sql.token.generator.SQLTokenGenerators.generateSQLTokens(SQLTokenGenerators.java:70)
        at 
org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext.generateSQLTokens(SQLRewriteContext.java:83)
        at 
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.createSQLRewriteContext(SQLRewriteEntry.java:78)
        at 
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.rewrite(SQLRewriteEntry.java:70)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:59)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:47)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:115)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:67)
        at 
org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
        at 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:62)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:96)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:69)
        at 
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
        at 
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
        at 
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to