I've been getting this error every so often which follows:
ERROR - Database exception occurred System.InvalidOperationException: Internal connection fatal error. at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryCloseInternal(Boolean closeReader) at System.Data.SqlClient.SqlDataReader.Close() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior) in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:line 235 at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass4.<ExecuteReaderWithRetry>b__3() at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) at Umbraco.Core.Persistence.Database.<Query>d__7`1.MoveNext()
This seems to happen with only one specific method in the database, which follows:
public ProductViewModel GetById(int id)
{
var productViewModel = new ProductViewModel();
if (id <= 0) return productViewModel;
using (var tr = _db.GetTransaction())
{
// Get the basic product information from the DB.
var product = _db.SingleOrDefault<Product>("SELECT * FROM Products WHERE Id = @0", id);
// Bind direct ProductViewModel's properties.
productViewModel = Mapper.Map<ProductViewModel>(product);
try
{
// Set the product's images
productViewModel.Images = GetPicturesById(product.Id).ToList();
// Set the Products Variants
productViewModel.Variants = GetProductsVariantsByProductId(product.Id);
// Set the Alternatives Products
productViewModel.Alternatives = GetAlternativesProductsById(product.Id);
// Set the Cross-sells Products
productViewModel.CrossSells = GetCrossSellsProductsById(product.Id);
// Set the Product SEO
productViewModel.Seo = GetProductSeoById(product.Id);
// Set the Size guide
productViewModel.SizeGuide = _sizeGuidesRepository.GetById(product.SizeGuideTopicId);
// Set the brand
productViewModel.Brand = GetBrandById(productViewModel.Id);
// Set the Market Sectors
productViewModel.MarketSectorIds = GetMarketSectorsById(productViewModel.Id);
// Set the Product Features
productViewModel.ProductFeatures = GetProductFeaturesById(productViewModel.Id);
// Set the Product News Ids
productViewModel.RelatedNewsIds = GetProductNewsById(productViewModel.Id);
tr.Complete();
}
catch (Exception e)
{
_log.Error(string.Format(@"Product Details - Id:{0}, Images:{1}, Variants:{2}, Alternatives:{3}, CrossSells:{4}, Seo:{5}, SizeGuide:{6}, Brand:{7}, Market Sectors:{8},
Features:{9}, RelatedNewsIds:{10}. Product Object: {11}", productViewModel.Id, productViewModel.Images, productViewModel.Variants,
productViewModel.Alternatives, productViewModel.CrossSells, productViewModel.Seo, productViewModel.SizeGuide, productViewModel.Brand,
productViewModel.MarketSectorIds, productViewModel.ProductFeatures, productViewModel.RelatedNewsIds), e);
}
}
return productViewModel;
}
As you can see there's a lot of calls within the Using statement, however I'm unsure whether the Using statement is needed.
The method GetCrossSellsProductsById has a Using statement within it too (so effectively, a nested Using).
Each method within the Using statement use Database methods such as Fetch etc.
As previously mentioned, this error only occurs a couple of times per week, and only on a live database.
So my questions are:
Are Using statements required for basic database transactions?
Umbraco Database Fatal Error
Hi I'm using Umbraco 7.5.11
I've been getting this error every so often which follows:
This seems to happen with only one specific method in the database, which follows:
As you can see there's a lot of calls within the Using statement, however I'm unsure whether the Using statement is needed.
The method GetCrossSellsProductsById has a Using statement within it too (so effectively, a nested Using).
Each method within the Using statement use Database methods such as Fetch etc.
As previously mentioned, this error only occurs a couple of times per week, and only on a live database.
So my questions are:
P.S. I know the code isn't very clean.
is working on a reply...