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

Multiple Connection Simple Execute #421

Merged
merged 7 commits into from
Jul 28, 2017

Conversation

anthonydresser
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling 6c3401d on bug/simpleExecuteMultipleConnections into e1395cb on master.

Copy link
Contributor

@kevcunnane kevcunnane left a 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);
Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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(){
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling 6c3401d on bug/simpleExecuteMultipleConnections into e1395cb on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling 6f4e4c2 on bug/simpleExecuteMultipleConnections into e1395cb on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling 92f0ad1 on bug/simpleExecuteMultipleConnections into e1395cb on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling 0808faa on bug/simpleExecuteMultipleConnections into e1395cb on master.

Copy link
Contributor

@benrr101 benrr101 left a 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(){
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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?

Copy link
Member

@kburtram kburtram left a 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.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.303% when pulling dbc8adc on bug/simpleExecuteMultipleConnections into e1395cb on master.

Copy link
Contributor

@benrr101 benrr101 left a 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

@anthonydresser anthonydresser merged commit 7ef81d0 into master Jul 28, 2017
@anthonydresser anthonydresser deleted the bug/simpleExecuteMultipleConnections branch July 28, 2017 20:35
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

Successfully merging this pull request may close these issues.

6 participants