Implement message archive for EF persistence - #5691
Conversation
There was a problem hiding this comment.
Note: the migration here shows up as a move in this PR because I had to delete the previous one that was not included in the snapshot for the migration that followed it. Deleting it and including it in this migration was the simplest path to making them consistent.
| @@ -1,5 +1,6 @@ | |||
| namespace ServiceControl.Persistence.EFCore.Abstractions; | |||
|
|
|||
| using Implementation.Recoverability; | |||
There was a problem hiding this comment.
It's where the class is, are we meant to be skipping Implementation from the namespace?
| public class ArchiveOperationEntity | ||
| { | ||
| /// <summary>The group id (or other request id) being archived/unarchived.</summary> | ||
| public string RequestId { get; set; } = null!; |
| public string RequestId { get; set; } = null!; | ||
|
|
||
| /// <summary>Display name of the group, captured at operation start.</summary> | ||
| public string GroupName { get; set; } = null!; |
| string[] batchIds; | ||
| do | ||
| { | ||
| logger.LogInformation("Archiving messages from group {GroupId} starting", groupId); |
There was a problem hiding this comment.
Should this be out of the loop?
| AuditArchivedMessages(MessageActionKind.Unarchive, Permissions.ErrorRecoverabilityGroupsUnarchive, auditUser, auditOperationId, batchIds); | ||
|
|
||
| logger.LogInformation("Unarchiving of {MessageCount} messages from group {GroupId} completed", batchIds.Length, groupId); | ||
| } while (batchIds.Length >= batchSize); |
There was a problem hiding this comment.
Technically it could be just == but I like to keep it safe.
|
|
||
| public Task<bool> MarkAsResolved(string failedMessageId) => | ||
| throw new NotImplementedException(); | ||
| var now = DateTime.UtcNow; |
There was a problem hiding this comment.
Not sure how you testing this yet but TimeProvider? Maybe later.
There was a problem hiding this comment.
That's a good point, this needs to be tested with the sweeper
This pull request introduces new archive-related entities to the EF Core persistence layer for both PostgreSQL and SQL Server, and updates the corresponding migration and model snapshot files. The main changes involve adding the
ArchiveOperationEntityand related tables, as well as updating or removing some fields and indexes to support new archiving and retry features.Key changes:
Archive and Retry Feature Additions
ArchiveOperationEntityand correspondingarchive_operationstable with fields for tracking archive operations, including batch and message counts, group info, and initiator details. [1] [2] [3]Schema and Index Updates
TypeandGroupIdfor thefailed_message_groupstable to optimize queries.Migration and Model Maintenance