nimo10050 opened a new issue, #20789:
URL: https://github.com/apache/shardingsphere/issues/20789

   ## Question
   
   If there is write operation in the same thread and database connection, 
**all the following read operations are not from the master database to ensure 
data consistency.**
   
   case:
   
    ```java
   public class AccountService {
       
       @Transactional
       public void test(String userId, BigDecimal num) {
           // step1,  in current transaction,  insert a data
           accountMapper.insertAccount(new Account(userId, num));
   
           // step2,  start a new transaction,  query all data
           accountService2.test();
   
           // step3, query all again.
           accountMapper.selectAll();
       }
   }
   
   public class AccountService2 {
   
       @Transactional(propagation = Propagation.REQUIRES_NEW)
       public void test() {
           accountMapper.selectAll();
       }
   
   }
   ```
   
   
   result:
   
   step1:insert data to master db
   step2:data from master db
   step3: query data from slave db
   
   when step1 and step3 in the same connection,step3 does not query data from 
master db。
   
   why ? @terrymanu 


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