[backend/database] Add Exception column to Job table
This commit is contained in:
parent
2e5e05872d
commit
3599150603
6 changed files with 41 additions and 3 deletions
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20240621171717_AddJobExceptionColumn")]
|
||||
public partial class AddJobExceptionColumn : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "exception",
|
||||
table: "jobs",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "exception",
|
||||
table: "jobs");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1559,6 +1559,10 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
|||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("delayed_until");
|
||||
|
||||
b.Property<string>("Exception")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("exception");
|
||||
|
||||
b.Property<string>("ExceptionMessage")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("exception_message");
|
||||
|
|
|
@ -32,6 +32,7 @@ public class Job
|
|||
[Column("exception_message")] public string? ExceptionMessage { get; set; }
|
||||
[Column("exception_source")] public string? ExceptionSource { get; set; }
|
||||
[Column("stack_trace")] public string? StackTrace { get; set; }
|
||||
[Column("exception")] public string? Exception { get; set; }
|
||||
[Column("data")] public string Data { get; set; } = null!;
|
||||
|
||||
[Column("worker_id")]
|
||||
|
|
|
@ -70,6 +70,7 @@ public class DeliverQueue(int parallelism)
|
|||
job.ExceptionMessage = e.Message;
|
||||
job.ExceptionSource = e.Source;
|
||||
job.StackTrace = e.StackTrace;
|
||||
job.Exception = e.ToString();
|
||||
job.DelayedUntil = DateTime.UtcNow + backoff;
|
||||
job.Status = Job.JobStatus.Delayed;
|
||||
}
|
||||
|
|
|
@ -500,6 +500,7 @@ public class PostgresJobQueue<T>(
|
|||
job.ExceptionMessage = e.Message;
|
||||
job.ExceptionSource = e.TargetSite?.DeclaringType?.FullName ?? "Unknown";
|
||||
job.StackTrace = e.StackTrace;
|
||||
job.Exception = e.ToString();
|
||||
|
||||
var queueName = data is BackgroundTaskJobData ? name + $" ({data.GetType().Name})" : name;
|
||||
if (e is GracefulException { Details: not null } ce)
|
||||
|
|
|
@ -84,21 +84,21 @@
|
|||
<td>@Model.Job.RetryCount</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Job.ExceptionMessage != null)
|
||||
@if (Model.Job is { ExceptionMessage: not null, Exception: null })
|
||||
{
|
||||
<tr>
|
||||
<td>Exception message</td>
|
||||
<td>@Model.Job.ExceptionMessage</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Job.ExceptionSource != null)
|
||||
@if (Model.Job is { ExceptionSource: not null, Exception: null })
|
||||
{
|
||||
<tr>
|
||||
<td>Exception source</td>
|
||||
<td>@Model.Job.ExceptionSource</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Job.StackTrace != null)
|
||||
@if (Model.Job is { StackTrace: not null, Exception: null })
|
||||
{
|
||||
<tr>
|
||||
<td>Exception stack trace</td>
|
||||
|
|
Loading…
Add table
Reference in a new issue