-
Notifications
You must be signed in to change notification settings - Fork 150
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
Multiple Connection Simple Execute #421
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks viable. I have a few suggestions that would be nice to get resolved but nothing truly blocking.
connInfo = null; | ||
executeStringParams.OwnerUri = executeParams.OwnerUri; | ||
} | ||
await ConnectionService.Connect(connectParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this throw? Generally we're wrapping every JSON-RPC message handler with a try/catch where any error results in a requestContext.SendError being sent over the channel. I think we need it here as there's plenty going on that could throw.
@@ -187,14 +190,21 @@ public void InitializeService(ServiceHost serviceHost) | |||
ConnectionInfo connInfo; | |||
if (!ConnectionService.TryFindConnection(executeParams.OwnerUri, out connInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I was confused by use of executeParams.OwnerUri
vs executeStringParams.OwnerUri
. One is the original request URI, the other is a random one used to ensure we have a dedicated connection. Given this, I'd suggest using a variable called randomUri
or newUri
instead of executeStringParams.OwnerUri
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@@ -218,6 +232,10 @@ public void InitializeService(ServiceHost serviceHost) | |||
{ | |||
await requestContext.SendError(SR.QueryServiceResultSetTooLarge); | |||
ActiveQueries.TryRemove(executeStringParams.OwnerUri, out removedQuery); | |||
ConnectionService.Disconnect(new DisconnectParams(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this a finally or something instead? You always want to disconnect, so let's ensure in the code that it happens no matter what the result of the query.
queryService.ActiveQueries.TryGetValue(Constants.OwnerUri, out q); | ||
|
||
// wait on the task to finish | ||
Query q = queryService.ActiveQueries.Values.First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a test that actually verifies we can run 2 queries against the same URI using this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is pretty much good to go. You'll want to make sure you cleanup the connection you create in all situations. Additionally, we may want to double check that creating a new connection like this doesn't introduce tons of overhead.
Query removedQuery; | ||
// remove the active query since we are done with it | ||
ActiveQueries.TryRemove(randomUri, out removedQuery); | ||
ConnectionService.Disconnect(new DisconnectParams(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want to disconnect in all scenarios, in other words, I'd move this to the outside try/catch/finally block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question @kburtram would know more.
ResultSetIndex = 0, | ||
RowsStartIndex = 0, | ||
RowsCount = Convert.ToInt32(rowCount) | ||
OwnerUri = randomUri, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By connecting with a random URI, doesn't this incur a lot of overhead by kicking off intellisense discovery and whatnot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach is fine for now. We'll need to optimize connection sharing in the connection service, so that the "connect" call doesn't actually open a new connect unless needed, but that should be done separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me
Changes simple execute to open a new connection on every request and close it when it is finished. I'm not convinced this is a good solution, but it does work, hoping someone else will have a better idea.