Skip to content

Commit

Permalink
Blocking large context collections
Browse files Browse the repository at this point in the history
  • Loading branch information
jgauffin committed Aug 29, 2019
1 parent 8f2b2ab commit cf4fede
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -25,8 +25,4 @@
<ItemGroup>
<EmbeddedResource Include="Schema\*.sql" />
</ItemGroup>

<ItemGroup>
<None Remove="Schema\Coderr.v17.sql" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions src/Server/Coderr.Server.SqlServer/ReportAnalyzer/Jobs/Importer.cs
Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Server/Coderr.Server.SqlServer/Schema/Coderr.v18.sql
@@ -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.