Skip to content

Commit 4fe6cd8

Browse files
committed
Add EF Core-backed failure group queries
Implements the read side of IGroupsDataStore for the SQL Server and PostgreSQL persisters. Groups are aggregated on the fly by joining FailedMessageGroups to FailedMessages and grouping by (GroupId, Title, Type)
1 parent 91ab6ee commit 4fe6cd8

12 files changed

Lines changed: 1142 additions & 37 deletions

File tree

src/ServiceControl.Persistence.EFCore.PostgreSql/Migrations/20260731043221_AddFailureGroupClassifierIndex.Designer.cs

Lines changed: 378 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace ServiceControl.Persistence.EFCore.PostgreSql.Migrations
6+
{
7+
/// <inheritdoc />
8+
public partial class AddFailureGroupClassifierIndex : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.CreateIndex(
14+
name: "ix_failed_message_groups_type_group_id",
15+
table: "failed_message_groups",
16+
columns: new[] { "type", "group_id" });
17+
}
18+
19+
/// <inheritdoc />
20+
protected override void Down(MigrationBuilder migrationBuilder)
21+
{
22+
migrationBuilder.DropIndex(
23+
name: "ix_failed_message_groups_type_group_id",
24+
table: "failed_message_groups");
25+
}
26+
}
27+
}

src/ServiceControl.Persistence.EFCore.PostgreSql/Migrations/PostgreSqlServiceControlDbContextModelSnapshot.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
305305
b.HasIndex("GroupId")
306306
.HasDatabaseName("ix_failed_message_groups_group_id");
307307

308+
b.HasIndex("Type", "GroupId")
309+
.HasDatabaseName("ix_failed_message_groups_type_group_id");
310+
308311
b.ToTable("failed_message_groups", (string)null);
309312
});
310313

src/ServiceControl.Persistence.EFCore.SqlServer/Migrations/20260731043129_AddFailureGroupClassifierIndex.Designer.cs

Lines changed: 308 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace ServiceControl.Persistence.EFCore.SqlServer.Migrations
6+
{
7+
/// <inheritdoc />
8+
public partial class AddFailureGroupClassifierIndex : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.CreateIndex(
14+
name: "IX_FailedMessageGroups_Type_GroupId",
15+
table: "FailedMessageGroups",
16+
columns: new[] { "Type", "GroupId" });
17+
}
18+
19+
/// <inheritdoc />
20+
protected override void Down(MigrationBuilder migrationBuilder)
21+
{
22+
migrationBuilder.DropIndex(
23+
name: "IX_FailedMessageGroups_Type_GroupId",
24+
table: "FailedMessageGroups");
25+
}
26+
}
27+
}

src/ServiceControl.Persistence.EFCore.SqlServer/Migrations/SqlServerServiceControlDbContextModelSnapshot.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
243243

244244
b.HasIndex("GroupId");
245245

246+
b.HasIndex("Type", "GroupId");
247+
246248
b.ToTable("FailedMessageGroups");
247249
});
248250

src/ServiceControl.Persistence.EFCore/EntityConfigurations/FailedMessageGroupConfiguration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public void Configure(EntityTypeBuilder<FailedMessageGroupEntity> builder)
1717

1818
builder.HasIndex(e => e.GroupId);
1919

20+
// Drives the per-classifier group aggregate, which filters on Type and groups by GroupId.
21+
builder.HasIndex(e => new { e.Type, e.GroupId });
22+
2023
builder.HasOne<FailedMessageEntity>()
2124
.WithMany()
2225
.HasForeignKey(e => e.FailedMessageUniqueId)

0 commit comments

Comments
 (0)