Skip to content
Permalink
Browse files

Blocking large context collections

  • Loading branch information...
jgauffin committed Aug 29, 2019
1 parent 8f2b2ab commit cf4fede7e0c38b9a5be094d69db7e5557973b557
@@ -69,7 +69,8 @@ OPEN OldReportsCursor
FETCH NEXT FROM OldReportsCursor INTO @ReportId
WHILE @@FETCH_STATUS = 0
-- don't lock jobs because one DB gets filled (cloud service)
WHILE @@FETCH_STATUS = 0 AND @counter < 10000
BEGIN
set @counter = @counter + 1
DELETE FROM ErrorReports WHERE Id = @ReportId
@@ -25,8 +25,4 @@
<ItemGroup>
<EmbeddedResource Include="Schema\*.sql" />
</ItemGroup>

<ItemGroup>
<None Remove="Schema\Coderr.v17.sql" />
</ItemGroup>
</Project>
@@ -4,13 +4,16 @@
using System.Threading.Tasks;
using Coderr.Server.Domain.Core.ErrorReports;
using Griffin.Data;
using log4net;

namespace Coderr.Server.SqlServer.ReportAnalyzer.Jobs
{
internal class Importer
{
private readonly SqlTransaction _transaction;
private readonly DataTable _dataTable = new DataTable();
private ILog _logger = LogManager.GetLogger(typeof(Importer));


public Importer(SqlTransaction transaction)
{
@@ -26,10 +29,17 @@ public void AddContextCollections(int reportId, ErrorReportContextCollection[] c
{
foreach (var context in contexts)
{
if (context.Properties.Count > 300)
{
_logger.Warn($"Report {reportId}, Ignoring collection {context.Name}, since it got {context.Properties.Count} properties");
continue;
}

foreach (var property in context.Properties)
{
if (property.Value == null)
continue;

var row = CreateDataTableRow(_dataTable, reportId, context, property);
_dataTable.Rows.Add(row);
}
@@ -0,0 +1,11 @@
IF EXISTS (SELECT * FROM sys.indexes WHERE name='IDX_ErrorReportCollectionProperties_ReportId'
AND object_id = OBJECT_ID('ErrorReportCollectionProperties'))
begin
CREATE INDEX IDX_ErrorReportCollectionProperties_ReportId
ON ErrorReportCollectionProperties (ReportId);

CREATE INDEX IDX_ErrorReportCollectionInbound_ReportId
ON ErrorReportCollectionInbound (ReportId);

end

0 comments on commit cf4fede

Please sign in to comment.
You can’t perform that action at this time.