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

need to close db connection if res is nil. #94

Open
zhiyong0804 opened this issue Sep 15, 2019 · 0 comments
Open

need to close db connection if res is nil. #94

zhiyong0804 opened this issue Sep 15, 2019 · 0 comments

Comments

@zhiyong0804
Copy link
Contributor

zhiyong0804 commented Sep 15, 2019

sw version : openresty 1.15.8.1, lua-resty-mysql commit id is 68f4841.
test step : 1. run the example of READ.md show, and if query failed will not call db:close

                 `
                     res, err, errcode, sqlstate = db:query("select * from catswhere id='100';") 
                     if not res then  
                            ngx.log(ngx.ERR, "bad result: ", err, ": ", errcode, ": ", sqlstate, ".");  
                            --db:close()  
                            return  
                      end  
                  `

             2.  check 3306 port status, there are so many TIME_WAIT socket

                  `
                      tcp        0      0 127.0.0.1:55532         127.0.0.1:3306          TIME_WAIT   -  
                      tcp        0      0 127.0.0.1:55534         127.0.0.1:3306          TIME_WAIT   -  
                 ` 

              3. add db:close when query res is nil, there is no any TIME_WAIT socket  

expect result : there is no any TIME_WAIT socket if query failed, so the examples show on README.md should add db:close if query failed.

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

No branches or pull requests

1 participant