dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.08k stars 2.03k forks source link

Add ADO and other configuration samples to Relational Storage page in documentation #3070

Closed dandago closed 7 years ago

dandago commented 7 years ago

I am attempting to use the ADO .NET Storage provider with MySQL, which according to the Storage Providers documentation should be supported.

The SiloHost is failing to start with the following exception text:

"Unable to find and/or load a candidate assembly for 'System.Data.SqlClient' invariant name."

I have tracked this to the DbConnectionFactory.cs file. Although I installed the MySql.Data package, Orleans still seems to be looking for the package needed if we were to work against SQL Server.

This might be related to the ADO .NET Invariants. For SQL Server, System.Data.SqlClient is both the name of the invariant and of the package/assembly. However this is not true for MySQL: the package/assembly is MySql.Data, whereas the invariant is MySql.Data.MySqlClient. If the connection code that looks for the assembly is working based on invariant name, this could explain why it works with SQL Server but not MySQL.

I am using Orleans 1.4.1.

dandago commented 7 years ago

Repro solution attached.

OrleansMySqlRepro.zip

attilah commented 7 years ago

Hi @dandago !

Thanks for the report and the repro project.

From that what I see is that you don't need the DbProviderFactories section in the Silo's app config for Orleans itself. On the other hand in the Silo configuration you need to specify AdoInvariant="MySql.Data.MySqlClient" within the Provider element to let Orleans know about what type of Ado.Net provider you like to use.

We've the same semantics as the System.Data supports with its own DbProviderFactories.

Please get back with the results and I will close the issue after that.

dandago commented 7 years ago

Hi @attilah,

Thank you for your response! You are right - it worked with the AdoInvariant you suggested. The DbProviderFactories entry was probably added automatically when I installed the MySql.Data package.

This AdoInvariant part needs to be better documented. I realise now that it is mentioned in the Relational Storage page, but I totally missed it. It needs to be available in the Grain Persistence page with clear examples.

Thanks again.

veikkoeeva commented 7 years ago

This is true. Offering a bit of frame, in .NET Core, it looked like DbProviderFactory was going away (now doing a come-back?). In current full .NET, the configuration would be in different place from the Orleans configuration, so perhaps confusing. Then there is also the aspect one might want to load different providers for different features.

This certainly needs to be documented better.

attilah commented 7 years ago

@dandago would you do an update to the documentation page and submit a PR with the suggested changes?

dandago commented 7 years ago

I believe this is best handled by anyone who knows the Storage Providers inside out. Aside from the issues I pointed out, there are other samples that I haven't gotten around to setting up (e.g. Posgres, and creating your own storage provider). The documentation on storage providers requires significant review that I would only be able to provide in part.

Having said that, if this can wait a little, I might find some time to experiment with storage providers a little, write a couple of blog posts for my site, and contribute the working samples for the documentation here. That might at least help a little.

By the way, the ADO .NET example refers to "Orleans.SqlUtils.StorageProvider.SqlStorageProvider", which I believe should be "AdoNetStorageProvider".

veikkoeeva commented 7 years ago

I'll cross-reference (@dandago) some other issues that might be useful:

In addition to that, I believe someone using ADO.NET providers should be interested of these things (for performance, QoS and disaster recovery reasons):

dandago commented 7 years ago

Thank you @veikkoeeva; this also sheds light on the PostgreSQL problems (#3085) which I reported yesterday, and which I have now updated accordingly.

The more I learn about Grain Persistence, the more I am developing the opinion that it should be its own section in the documentation, with different pages for each provider type, and examples in both XML and programmatic configuration for each. There would be a page on writing custom providers with an example. And the rationale (which is currently part in the Relational Storage page and part in the Grain Persistence page) would also be under this section.

veikkoeeva commented 7 years ago

Should this be closed via #3100, @sergeybykov?

sergeybykov commented 7 years ago

@veikkoeeva Indeed. Fixed via #3100.