Comments (4)
Is this the same problem as #91?
PR #109 attempts to fix that but is failing all the tests.
from go-mssqldb.
no, not quite the same. I think #91 actually describes expected behaviour, not a bug. After all, Ping() and Query() must block as long as the "pong" is yet to be seen and the TCP connection is still alive (which is usually well after the network cable is disconnected). The solution to issue #91 is "replace Ping by PingContext to avoid the halting problem", I think.
But for PingContext and QueryContext it is different, I would expect for them to abort once the context is done, "no matter what". They shouldn't wait for a slow network. It is the same loop that blocks though. So this present issue (and the identical denisenkom#527) needs some unblocking.
I'm a bit out of my depth. My best lead is this: readCancelConfirmation would need to (receive as a parameter and) consider the context, and stop blocking there. Maybe the connection could just be discarded and closed. Or the incoming tokens up until the cancellation confirmation would have to be consumed in the background.
from go-mssqldb.
Completely untested code below. This acts on
- the context being cancelled,
- new tokens coming in (anything up until a
doneStruct
is discarded), - or the token channel being closed (after a network error)
- and blocks while neither of the three occurs.
// consume tokens until we get cancellation confirmation, or until context is done
func readCancelConfirmation(ctx context.Context, tokChan chan tokenStruct) bool {
for {
select {
case <-ctx.Done():
// this should in effect discard the connection. Debatable.
return false
case tok, alive := <-tokChan:
if !alive {
// tokChan is closed.
return false
}
confirmToken, isConfirmation := tok.(*doneStruct)
if isConfirmation && (confirmToken.Status&doneAttn != 0) {
// got cancellation confirmation, the connection is usable again
return true
}
}
}
}
Actually it is debatable if QueryContext
may discard the connection just because the context is cancelled. It seems to depend on the semantics of "cancelling". For example, in an interactive environment like sqlcmd
, the user could say "I see, the query takes too long. Abort this operation, but let me resume with the same connection." They'd have to wait then.
from go-mssqldb.
Related Issues (20)
- ..\pkg\mod\github.com\microsoft\[email protected]\tds.go:489:20: 0xFFFFFFF8 (untyped int constant 4294967288) overflows int HOT 1
- TDS8 - Add "Strict", "mandatory" and "optional" options for encrypt
- TDS8: Accept certificate location as part of connection property 'TrustServerCertificate HOT 1
- Add support for DER and CER format certificates
- Implement "change password"
- Add an example for Always Encrypted
- add a context.Context parameter to always encrypted interfaces
- Add AAD device code authentication
- connection fails when using specific connection string with specific password HOT 6
- Add environment variable and default path support to Kerberos auth package
- Connection Error 17830 logged to extended events when connecting to servers with multiple IPs
- String output parameter value is cut off HOT 18
- can i use always encrypted with secure enclaves? HOT 1
- Use dockertest to instantiate the test database HOT 2
- Is There Support For The HierarchyID Data Type? HOT 3
- Unable to open tcp connection with host 'localhost:1443': dial tcp 127.0.0.1:1443 HOT 4
- tdsBuffer data race in transaction query with OUTPUT HOT 1
- connection not closed when database name is incorrect HOT 1
- Support prelogin response with packet type 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mssqldb.