Fix: Outbox relay has no dead-letter or max retry limit + DataLake writer partial commit inconsistency + ThresholdCacheLoader crashes startup on Redis failure

This commit is contained in:
voltsrage
2026-06-21 17:43:37 +08:00
parent 2d22ff06b6
commit 33895122d1
9 changed files with 1471 additions and 56 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareClinicalAPI.Migrations
{
/// <inheritdoc />
public partial class AddOutboxRetryColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_outbox_events_created_at",
table: "outbox_events");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "failed_at",
table: "outbox_events",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "last_error",
table: "outbox_events",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "retry_count",
table: "outbox_events",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_outbox_events_created_at",
table: "outbox_events",
column: "created_at",
filter: "processed_at IS NULL AND failed_at IS NULL");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_outbox_events_created_at",
table: "outbox_events");
migrationBuilder.DropColumn(
name: "failed_at",
table: "outbox_events");
migrationBuilder.DropColumn(
name: "last_error",
table: "outbox_events");
migrationBuilder.DropColumn(
name: "retry_count",
table: "outbox_events");
migrationBuilder.CreateIndex(
name: "IX_outbox_events_created_at",
table: "outbox_events",
column: "created_at",
filter: "processed_at IS NULL");
}
}
}
@@ -763,6 +763,14 @@ namespace VigilCareClinicalAPI.Migrations
.HasColumnName("created_at")
.HasDefaultValueSql("NOW()");
b.Property<DateTimeOffset?>("FailedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("failed_at");
b.Property<string>("LastError")
.HasColumnType("text")
.HasColumnName("last_error");
b.Property<string>("PartitionKey")
.HasMaxLength(36)
.HasColumnType("character varying(36)")
@@ -777,6 +785,12 @@ namespace VigilCareClinicalAPI.Migrations
.HasColumnType("timestamp with time zone")
.HasColumnName("processed_at");
b.Property<int>("RetryCount")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasColumnName("retry_count");
b.Property<string>("Topic")
.IsRequired()
.HasMaxLength(200)
@@ -786,7 +800,7 @@ namespace VigilCareClinicalAPI.Migrations
b.HasKey("Id");
b.HasIndex("CreatedAt")
.HasFilter("processed_at IS NULL");
.HasFilter("processed_at IS NULL AND failed_at IS NULL");
b.ToTable("outbox_events", (string)null);
});