markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

Invalid DatabaseSchema is cached: Never recover from a DB previously down #354

Open jdoose opened 9 years ago

jdoose commented 9 years ago

DB down on program startup - Simple.Data will never be able to connect to the DB after the DB start. DB up on program startup - Simple.Data will be able to reconnect to DB even after the DB was down and up again.

tried with ClearAllPools and ClearAdapterCache as well. I am connecting to an SqlServer, using version 0.19 of SimpleData.

Same circumstances works fine with the Ado-Classes.

Workaround: Call DatabaseSchema.ClearCache();

Reason: in DatabaseSchema:Get(IConnectionProvider connectionProvider, ProviderHelper providerHelper) the schema information is cached even when it later cannot be retrieved (when the connection to the database could not be made). From this point on the (invalid) cached information is used which means that data can never be read from this database (this table?) again.

Probably it would be better if the information is only cached when the database connection could be made. Or the cached object would be deleted if the database connection could not be made

More description: https://groups.google.com/forum/#!topic/simpledata/qPwJMdaZ37o

Porkstone commented 9 years ago

I experienced this in a web site. I was getting an ado error complaining that a column didn't exist after I dropped a column. As jdoose suggested calling DatabaseSchema.ClearCache(); resolved the issue.