summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/dereferencer.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-06-06 08:50:14 +0000
committerLibravatar GitHub <noreply@github.com>2024-06-06 10:50:14 +0200
commit3b7faac604000297b74baf8f922c79c6b387217d (patch)
tree05b1d32eeaa902571a9ec1fb0d643a08b9be2a86 /internal/federation/dereferencing/dereferencer.go
parent[chore] Fiddle with CI tests; use wasmsqlite3 for CI tests (#2966) (diff)
downloadgotosocial-3b7faac604000297b74baf8f922c79c6b387217d.tar.xz
[bugfix] concurrent map writes in dereferencer media processing maps (#2964)
* removes the avatar / header deref maps as we now have per-uri status / account locks, adds retries on data-races, adds separate emoji map mutex * work with a copy of account / status for each retry loop * revert to old data race behaviour, it gets too complicated otherwise --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/federation/dereferencing/dereferencer.go')
-rw-r--r--internal/federation/dereferencing/dereferencer.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/internal/federation/dereferencing/dereferencer.go b/internal/federation/dereferencing/dereferencer.go
index 3fa199345..f7f4d975e 100644
--- a/internal/federation/dereferencing/dereferencer.go
+++ b/internal/federation/dereferencing/dereferencer.go
@@ -85,11 +85,22 @@ type Dereferencer struct {
mediaManager *media.Manager
visibility *visibility.Filter
- // all protected by State{}.FedLocks.
- derefAvatars map[string]*media.ProcessingMedia
- derefHeaders map[string]*media.ProcessingMedia
- derefEmojis map[string]*media.ProcessingEmoji
+ // in-progress dereferencing emoji. we already perform
+ // locks per-status and per-account so we don't need
+ // processing maps for other media which won't often
+ // end up being repeated. worst case we run into an
+ // db.ErrAlreadyExists error which then gets handled
+ // appropriately by enrich{Account,Status}Safely().
+ derefEmojis map[string]*media.ProcessingEmoji
+ derefEmojisMu sync.Mutex
+ // handshakes marks current in-progress handshakes
+ // occurring, useful to prevent a deadlock between
+ // gotosocial instances attempting to dereference
+ // accounts for the first time. when a handshake is
+ // currently ongoing we know not to block waiting
+ // on certain data and instead return an in-progress
+ // form of the data as we currently see it.
handshakes map[string][]*url.URL
handshakesMu sync.Mutex
}
@@ -108,8 +119,6 @@ func NewDereferencer(
transportController: transportController,
mediaManager: mediaManager,
visibility: visFilter,
- derefAvatars: make(map[string]*media.ProcessingMedia),
- derefHeaders: make(map[string]*media.ProcessingMedia),
derefEmojis: make(map[string]*media.ProcessingEmoji),
handshakes: make(map[string][]*url.URL),
}