[backend/core] Also use the NoteService KeyedLocker when it's called from ActivityHandlerService
This fixes sporadic "Unique constraint violation" exceptions on the "IX_note_uri" index.
This commit is contained in:
parent
4be51a0cad
commit
093abe82b8
2 changed files with 6 additions and 2 deletions
|
@ -105,7 +105,8 @@ public class ActivityHandlerService(
|
|||
activity.Object = await objectResolver.ResolveObject(activity.Object, actor.Uri) as ASNote ??
|
||||
throw GracefulException.UnprocessableEntity("Failed to resolve create object");
|
||||
|
||||
await noteSvc.ProcessNoteAsync(activity.Object, actor, inboxUser);
|
||||
using (await NoteService.GetNoteProcessLockAsync(activity.Object.Id))
|
||||
await noteSvc.ProcessNoteAsync(activity.Object, actor, inboxUser);
|
||||
}
|
||||
|
||||
private async Task HandleDelete(ASDelete activity, User resolvedActor)
|
||||
|
@ -335,7 +336,8 @@ public class ActivityHandlerService(
|
|||
await userSvc.UpdateUserAsync(resolvedActor, actor);
|
||||
break;
|
||||
case ASNote note:
|
||||
await noteSvc.ProcessNoteUpdateAsync(note, resolvedActor);
|
||||
using (await NoteService.GetNoteProcessLockAsync(note.Id))
|
||||
await noteSvc.ProcessNoteUpdateAsync(note, resolvedActor);
|
||||
break;
|
||||
default:
|
||||
logger.LogDebug("Like activity object is unknown, skipping");
|
||||
|
|
|
@ -715,6 +715,8 @@ public class NoteService(
|
|||
eventSvc.RaiseNoteDeleted(this, hit);
|
||||
}
|
||||
|
||||
public static ValueTask<IDisposable> GetNoteProcessLockAsync(string uri) => KeyedLocker.LockAsync(uri);
|
||||
|
||||
public async Task<Note?> ProcessNoteAsync(ASNote note, User actor, User? user = null)
|
||||
{
|
||||
var dbHit = await db.Notes.IncludeCommonProperties().FirstOrDefaultAsync(p => p.Uri == note.Id);
|
||||
|
|
Loading…
Add table
Reference in a new issue