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

unit tests corrupt data potentially #29408

Open
freemine opened this issue Dec 30, 2024 · 1 comment
Open

unit tests corrupt data potentially #29408

freemine opened this issue Dec 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@freemine
Copy link
Contributor

freemine commented Dec 30, 2024

Bug Description
taosd can not be restarted successfully after finishing running all unit tests

To Reproduce
Steps to reproduce the behavior:

1. git clone ...                                                                                                                                                                
2. cd <TDengine>                                                                
3. cmake -B debug -DWEBSOCKET=true -DBUILD_TOOLS=true -DBUILD_CONTRIB=true -DBUILD_HTTP=false -DBUILD_TEST=true
4. cmake --build debug                                                          
5. sudo cmake --install debug                                                   
6. sudo systemctl start taosd                                                   
7. sudo systemctl start taosadapter                                             
8. taos -s 'show databases' # success fresh new                                 
9. pushd debug && ctest; popd                                                   
10. taos -s 'show databases' # success after all unit tests                     
11. sudo systemctl stop taosadapter                                             
12. sudo systemctl stop taosd                                                   
13. sudo systemctl start taosd                                                  
14. sudo systemctl start taosadapter                                            
15. taos -s 'show databases'   # timeout after taosd restart                    
16. sudo systemctl stop taosadapter                                             
17. sudo systemctl stop taosd                                                   
18. sudo rm -rf /var/lib/taos                                                   
19. sudo systemctl start taosd                                                  
20. sudo systemctl start taosadapter                                            
21. taos -s 'show databases' # success after reconstruct taosd data (NOTE: taosd process exists, but internal logic failed)

Expected Behavior
unit tests shall NOT make taosd failed restarted or even badly, corrupt whole database

Screenshots

Environment (please complete the following information):

  • OS: [Linux xxh-virtual-machine 6.8.0-40-generic # 40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux]
  • TDengine Version [3.3.5]

Additional Context
git commit: e5f617db796cd7110b7efe26dd24095e55128a68

@freemine freemine added the bug Something isn't working label Dec 30, 2024
@freemine
Copy link
Contributor Author

freemine commented Jan 2, 2025

after digging into unit test cases and here after is the result(ref:source/client/test/clientTest.cpp):
the root cause is : some arbitrary dnode was requested to be created but failed to drop for the test cases,
which results in leader synchronization failure during taosd-restart-procedure.
ref:source/client/test/clientTest.cpp

TEST(clientCase, drop_dnode_Test) {                                                 
  TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);             
  ASSERT_NE(pConn, nullptr);                                                        
                                                                                    
  TAOS_RES* pRes = taos_query(pConn, "drop dnode 3");                               
  if (taos_errno(pRes) != 0) {                                                      
    (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));            
  }                                                                                 
                                                                                    
  TAOS_FIELD* pFields = taos_fetch_fields(pRes);                                    
  ASSERT_TRUE(pFields == NULL);                                                     
                                                                                    
  int32_t numOfFields = taos_num_fields(pRes);                                      
  ASSERT_EQ(numOfFields, 0);                                                        
  taos_free_result(pRes);                                                           
                                                                                    
  pRes = taos_query(pConn, "drop dnode 4");                                         
  if (taos_errno(pRes) != 0) {                                                      
    (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes));            
  }                                                                                 
                                                                                    
  taos_free_result(pRes);                                                           
  taos_close(pConn);                                                                
}                                                                                   
                                                                                    
TEST(clientCase, use_db_test) {                                                     
  TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);             
  ASSERT_NE(pConn, nullptr);                                                        
                                                                                    
  TAOS_RES* pRes = taos_query(pConn, "use abc1");                                   
  if (taos_errno(pRes) != 0) {                                                      
    (void)printf("error in use db, reason:%s\n", taos_errstr(pRes));                
  }                                                                                 
                                                                                    
  TAOS_FIELD* pFields = taos_fetch_fields(pRes);                                    
  ASSERT_TRUE(pFields == NULL);                                                     
                                                                                    
  int32_t numOfFields = taos_num_fields(pRes);                                      
  ASSERT_EQ(numOfFields, 0);                                                        
                                                                                    
  taos_free_result(pRes);                                                           
  taos_close(pConn);                                                                
}                                                                                   

@yu285 yu285 self-assigned this Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants