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

Configure MARS in SqlServer #21420

Closed
smitpatel opened this issue Jun 26, 2020 · 6 comments · Fixed by #21456
Closed

Configure MARS in SqlServer #21420

smitpatel opened this issue Jun 26, 2020 · 6 comments · Fixed by #21456
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@smitpatel
Copy link
Contributor

Since we have split queries again, SqlServer may fail without MARS.
We could add DbOption configuration for users to tell us if they have MARS on or not.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jun 26, 2020

Is MARS not already specified in the connection string?

@smitpatel
Copy link
Contributor Author

Yes, it is. I guess we can just evaluate the connection string and determine too. I don't know how we did in 2.x.
Mainly in query we need flag that if MARS is on or not so we can appropriately buffer for split query scenario so exception is not thrown.

@smitpatel
Copy link
Contributor Author

public override bool IsMultipleActiveResultSetsEnabled
=> (bool)(_multipleActiveResultSetsEnabled
?? (_multipleActiveResultSetsEnabled
= new SqlConnectionStringBuilder(ConnectionString).MultipleActiveResultSets));

@ajcvickers
Copy link
Contributor

Note from triage: we will try bringing back the 2.2 code for this. We should also decide whether or not to assume that a provider can do MARS.

@roji
Copy link
Member

roji commented Jun 26, 2020

For other providers implementing preview6, the current implementation of query splitting assumes MARS capabilities by default, and so will fail if the provider doesn't support them. To make EF Core buffer instead, create your own subclass of RelationalQueryCompilationContext (defining a factory that returns it, and registering that factory with EF Core), with the following:

public override bool IsBuffering => base.IsBuffering || IsSplitQuery;

Since MARS once again is an exception in the provider landscape (although it happens to be supported by Sqlite and SQL Server when enabled), I really think it would be better to not require all providers to do this - discoverability is going to be difficult, and the buffering behavior will always work across all providers, where MARS is strictly-speaking an optimization only. It seems pretty trivial for RelationalQCC to expose a hook that allows Sqlite and SQL Server to opt in, rather than forcing everyone else to opt out.

/cc @lauxjpn

roji added a commit to npgsql/efcore.pg that referenced this issue Jun 26, 2020
Otherwise MARS is assumed by EF Core, which we don't support.

See dotnet/efcore#21420
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 29, 2020
@ghost ghost closed this as completed in #21456 Jun 29, 2020
ghost pushed a commit that referenced this issue Jun 29, 2020
@lauxjpn
Copy link
Contributor

lauxjpn commented Jul 1, 2020

Since MARS once again is an exception in the provider landscape (although it happens to be supported by Sqlite and SQL Server when enabled), I really think it would be better to not require all providers to do this - discoverability is going to be difficult, and the buffering behavior will always work across all providers, where MARS is strictly-speaking an optimization only. It seems pretty trivial for RelationalQCC to expose a hook that allows Sqlite and SQL Server to opt in, rather than forcing everyone else to opt out.

I second that. EF Core should default to the most common/reasonable approach across the provider landscape, not the SQL Server implementation.

@ajcvickers ajcvickers added this to the 5.0.0 milestone Nov 7, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants