denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.81k stars 493 forks source link

Bug fix: Mark connection as not good when error on cancellation confirmation #773

Open zcolleen opened 1 year ago

zcolleen commented 1 year ago

This pr fixes bug when we were not able to get cancelation confirmation but connection is not marked as bad and returns to pool, so next time this connection is taken from pool, we get the same error instead of opening new good connection

Example:

r, err := db.QueryContext(ctx, query) <- context expired, then we got cancelation confirmation error

...

r, err := db.QueryContext(ctx, query) <- we get same error because we are still using bad connection instead of opening new one

codecov[bot] commented 1 year ago

Codecov Report

Merging #773 (2fc4276) into master (ed0f620) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #773      +/-   ##
==========================================
+ Coverage   71.35%   71.38%   +0.02%     
==========================================
  Files          24       24              
  Lines        5405     5407       +2     
==========================================
+ Hits         3857     3860       +3     
+ Misses       1303     1302       -1     
  Partials      245      245              
Impacted Files Coverage Δ
mssql.go 87.78% <100.00%> (+0.03%) :arrow_up:
token.go 64.35% <100.00%> (+0.14%) :arrow_up:
tds.go 65.85% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more