From c31f21904c10f304e40cfbcb9bab9b4099e15e95 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:50:29 +0200 Subject: [PATCH] [bugfix] Use background context instead of request context for async processing (#888) Fixes an issue where async processing was not completing correctly. In particular this applies to side effects of domain blocks: while the domain block was being entered and enforced correctly, side effects like deleting accounts and updating the instance entry for the blocked instance were not. This fixes that :) --- internal/processing/admin/createdomainblock.go | 4 +++- internal/processing/admin/mediaprune.go | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/processing/admin/createdomainblock.go b/internal/processing/admin/createdomainblock.go index fcc0cb48..69016015 100644 --- a/internal/processing/admin/createdomainblock.go +++ b/internal/processing/admin/createdomainblock.go @@ -75,7 +75,9 @@ func (p *processor) DomainBlockCreate(ctx context.Context, account *gtsmodel.Acc block = &newBlock // Process the side effects of the domain block asynchronously since it might take a while - go p.initiateDomainBlockSideEffects(ctx, account, block) + go func() { + p.initiateDomainBlockSideEffects(context.Background(), account, block) + }() } // Convert our gts model domain block into an API model diff --git a/internal/processing/admin/mediaprune.go b/internal/processing/admin/mediaprune.go index 40652c3c..c7fbbdc1 100644 --- a/internal/processing/admin/mediaprune.go +++ b/internal/processing/admin/mediaprune.go @@ -33,7 +33,7 @@ func (p *processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gt } go func() { - pruned, err := p.mediaManager.PruneAllRemote(ctx, mediaRemoteCacheDays) + pruned, err := p.mediaManager.PruneAllRemote(context.Background(), mediaRemoteCacheDays) if err != nil { log.Errorf("MediaPrune: error pruning remote cache: %s", err) } else { @@ -42,7 +42,7 @@ func (p *processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gt }() go func() { - pruned, err := p.mediaManager.PruneUnusedLocalAttachments(ctx) + pruned, err := p.mediaManager.PruneUnusedLocalAttachments(context.Background()) if err != nil { log.Errorf("MediaPrune: error pruning unused local cache: %s", err) } else { @@ -51,7 +51,7 @@ func (p *processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gt }() go func() { - pruned, err := p.mediaManager.PruneAllMeta(ctx) + pruned, err := p.mediaManager.PruneAllMeta(context.Background()) if err != nil { log.Errorf("MediaPrune: error pruning meta: %s", err) } else {