alice-yang94 opened a new issue #14591:
URL: https://github.com/apache/shardingsphere/issues/14591


   ## Bug Report
   
   
   ### Which version of ShardingSphere did you use?
   - ShardingSphere 5.1.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   -  ShardingSphere-Proxy
   
   ### Background environment
   When using MogDB_v2.1.0.3 (same as openGauss 2.1.0) to set up one primary 
database, two standby databases and using switchover or failover on one of the 
standby database. After switchover or failover, the current standby database is 
switched to primary as the new primary database. The original primary database 
is switched as a standby database.
   
   ### Expected behavior
   ShardingSphere proxy's discovery module should recognise the new primary 
database and continue with new primary and standby databases.  
   
   ### Actual behavior
   ShardingSphere proxy's discovery module does not recognise the change of new 
primary database
   
   - For switchover, ShardingSphere proxy has error: An exception occurred 
while find primary data source url. When trying to connect and execute sql DDL 
commands,  ShardingSphere proxy has error:cannot execute UPDATE in a read-only 
transaction. 
   
   - For failover, ShardingSphere proxy has error: Connection is not available. 
The error log keeps trying to connect to the old primary database and cause the 
connection fail
   
   ### Reason analyze (If you can)
   
   ShardingSphere proxy's discovery module does not recognise the change of new 
primary database.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   1. environment:
   - MogDB_v2.1.0.3 (release_MogDB_openEuler_ARM64 和
   release_MogDB_CentOS_x86)
   - Zookeeper 3.7.0
   - ShardingSphere 5.1.0
   - sysbench: https://github.com/akopytov/sysbench/tree/master/src
   
   2. set up 1 primary, 2 standby databases according to mogdb docs
   3. start zookeeper and sharding sphere proxy
   ```
   [wenke@node156 wenke]$ cat 
apache-shardingsphere-5.1.0-shardingsphere-proxy-bin/conf/config-db-discovery.yaml
   schemaName: rwsplit_test_db
   dataSources:
     replica_ds_0:
       url: 
jdbc:postgresql://172.16.3.156:12000/postgres?serverTimezone=UTC&useSSL=false
       username: test1
       password: Qwer1234
       connectionTimeoutMilliseconds: 300
       idleTimeoutMilliseconds: 600
       maxLifetimeMilliseconds: 1200
       maxPoolSize: 1000
       minPoolSize: 200
     replica_ds_1:
       url: 
jdbc:postgresql://172.16.3.156:13000/postgres?serverTimezone=UTC&useSSL=false
       username: test1
       password: Qwer1234
       connectionTimeoutMilliseconds: 300
       idleTimeoutMilliseconds: 600
       maxLifetimeMilliseconds: 1200
       maxPoolSize: 1000
       minPoolSize: 200
     replica_ds_2:
       url: 
jdbc:postgresql://172.16.3.156:14000/postgres?serverTimezone=UTC&useSSL=false
       username: test1
       password: Qwer1234
       connectionTimeoutMilliseconds: 300
       idleTimeoutMilliseconds: 600
       maxLifetimeMilliseconds: 1200
       maxPoolSize: 1000
       minPoolSize: 200
   rules:
   - !READWRITE_SPLITTING
     dataSources:
       rd_rs:
         autoAwareDataSourceName: pr_ds
   - !DB_DISCOVERY
     dataSources:
       pr_ds:
         dataSourceNames:
             - replica_ds_0
             - replica_ds_1
             - replica_ds_2
         discoveryHeartbeatName: og-heartbeat
         discoveryTypeName: og
     discoveryHeartbeats:
       og-heartbeat:
         props:
           keep-alive-cron: '0/5 * * * * ?'
     discoveryTypes:
       og:
         type: openGauss
         props:
           group-name: 92504d5b-6dec-11e8-91ea-246e9612aaf1
   ```
   4. sysbench command executed: 
   ```
   sysbench oltp_read_write --db-driver=pgsql --pgsql-host=localhost 
--pgsql-port=3307 --pgsql-user=test1 --pgsql-password=Qwer1234 
--pgsql-db=rwsplit_test_db --skip_trx --tables=10 --table-size=1000000 
--threads=64 --report-interval=1 --time=1800 run
   ```
   5. execute switchover or failover
   5.1 switchover
   ```
   [standby1]$ bin/gs_ctl -D data_dir switchover
   ```
   ss switchover error screenshots:
   
   ![156-switchover后连ss不可写read 
only](https://user-images.githubusercontent.com/18554444/148489790-343af7b6-eebd-44f2-a1d1-806ccab804c6.png)
   ![switchover时ss报错找不到primary 
source](https://user-images.githubusercontent.com/18554444/148489857-fc4cfb03-9b2f-41be-96ea-da658e4b9f0a.png)
   
   5.2 failover
   ```
   [primary]$ bin/gs_ctl -D data_dir stop
   [standby1]$ bin/gs_ctl -D data_dir failover
   ```
   ss failover error screenshots:
   
   
   
![156-failover后仍试图重连原主库](https://user-images.githubusercontent.com/18554444/148489895-29526f66-cad5-49a8-8f69-4537c316c499.png)
   
   


-- 
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