Skip to content

Commit f556664

Browse files
committed
Add persistence and replay for failed error imports
Introduces a new persistence mechanism for error messages that failed during their initial ingestion into ServiceControl. This ensures that these messages are reliably stored and can be re-processed at a later time. The new `FailedErrorImports` table stores the failed messages, including their headers, body, and exception information. A deduplication mechanism ensures that repeated failures of the same message only update the existing record with the latest details.
1 parent 999b5da commit f556664

13 files changed

Lines changed: 1272 additions & 6 deletions

File tree

‎src/ServiceControl.Persistence.EFCore.PostgreSql/Migrations/20260727055109_AddFailedErrorImports.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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace ServiceControl.Persistence.EFCore.PostgreSql.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class AddFailedErrorImports : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.CreateTable(
15+
name: "failed_error_imports",
16+
columns: table => new
17+
{
18+
unique_message_id = table.Column<Guid>(type: "uuid", nullable: false),
19+
failed_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
20+
message_id = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
21+
headers_json = table.Column<string>(type: "text", nullable: false),
22+
body = table.Column<byte[]>(type: "bytea", nullable: false),
23+
body_stored_externally = table.Column<bool>(type: "boolean", nullable: false),
24+
exception_info = table.Column<string>(type: "text", nullable: false)
25+
},
26+
constraints: table =>
27+
{
28+
table.PrimaryKey("pk_failed_error_imports", x => x.unique_message_id);
29+
});
30+
31+
migrationBuilder.CreateIndex(
32+
name: "ix_failed_error_imports_failed_at",
33+
table: "failed_error_imports",
34+
column: "failed_at");
35+
}
36+
37+
/// <inheritdoc />
38+
protected override void Down(MigrationBuilder migrationBuilder)
39+
{
40+
migrationBuilder.DropTable(
41+
name: "failed_error_imports");
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)