[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,6 +105,7 @@ public class ActivityHandlerService(
|
||||||
activity.Object = await objectResolver.ResolveObject(activity.Object, actor.Uri) as ASNote ??
|
activity.Object = await objectResolver.ResolveObject(activity.Object, actor.Uri) as ASNote ??
|
||||||
throw GracefulException.UnprocessableEntity("Failed to resolve create object");
|
throw GracefulException.UnprocessableEntity("Failed to resolve create object");
|
||||||
|
|
||||||
|
using (await NoteService.GetNoteProcessLockAsync(activity.Object.Id))
|
||||||
await noteSvc.ProcessNoteAsync(activity.Object, actor, inboxUser);
|
await noteSvc.ProcessNoteAsync(activity.Object, actor, inboxUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +336,7 @@ public class ActivityHandlerService(
|
||||||
await userSvc.UpdateUserAsync(resolvedActor, actor);
|
await userSvc.UpdateUserAsync(resolvedActor, actor);
|
||||||
break;
|
break;
|
||||||
case ASNote note:
|
case ASNote note:
|
||||||
|
using (await NoteService.GetNoteProcessLockAsync(note.Id))
|
||||||
await noteSvc.ProcessNoteUpdateAsync(note, resolvedActor);
|
await noteSvc.ProcessNoteUpdateAsync(note, resolvedActor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -715,6 +715,8 @@ public class NoteService(
|
||||||
eventSvc.RaiseNoteDeleted(this, hit);
|
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)
|
public async Task<Note?> ProcessNoteAsync(ASNote note, User actor, User? user = null)
|
||||||
{
|
{
|
||||||
var dbHit = await db.Notes.IncludeCommonProperties().FirstOrDefaultAsync(p => p.Uri == note.Id);
|
var dbHit = await db.Notes.IncludeCommonProperties().FirstOrDefaultAsync(p => p.Uri == note.Id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue