From 3cff4b2d7d138f45787a94e6e64acdccb00e8951 Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 15 May 2025 09:40:48 +0000 Subject: [chore] various federatingdb tweaks (#4178) after seeing a potential reported federating worker lockup i decided to start digging into the federatingdb code. this PR encompasses: - removes one of our last unused interface types `federatingdb.DB{}`, replacing it with a struct type `*federatingdb.DB{}` - in `transport.dereferenceLocal()` differentiates between an unsupported lookup type and ErrNoEntries to reduce unnecessary calls, and reduce potential lockups that may occur while trying to call our own endpoints that then call `federatingdb.Lock()` - removes a bunch of the locks on follow state changes since the DB already synchronizes that - removes the unnecessary `pub.Clock{}` struct field and type passed to the transport controller frankly it would be great if we could remove the locking in `federatingdb.Lock()` and instead handle it ourselves as it gets very confusing trying to figure out what functions will have locks held. but i guess that's one for when we move further away from the go-fed/activity/pub package usage. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4178 Co-authored-by: kim Co-committed-by: kim --- testrig/federatingdb.go | 2 +- testrig/transportcontroller.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'testrig') diff --git a/testrig/federatingdb.go b/testrig/federatingdb.go index 28c6bd7b4..360f99db6 100644 --- a/testrig/federatingdb.go +++ b/testrig/federatingdb.go @@ -27,7 +27,7 @@ import ( ) // NewTestFederatingDB returns a federating DB with the underlying db -func NewTestFederatingDB(state *state.State) federatingdb.DB { +func NewTestFederatingDB(state *state.State) *federatingdb.DB { return federatingdb.New( state, typeutils.NewConverter(state), diff --git a/testrig/transportcontroller.go b/testrig/transportcontroller.go index 34ed35255..641232b73 100644 --- a/testrig/transportcontroller.go +++ b/testrig/transportcontroller.go @@ -31,7 +31,6 @@ import ( "code.superseriousbusiness.org/activity/streams/vocab" "code.superseriousbusiness.org/gotosocial/internal/ap" apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model" - "code.superseriousbusiness.org/gotosocial/internal/federation" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" "code.superseriousbusiness.org/gotosocial/internal/httpclient" "code.superseriousbusiness.org/gotosocial/internal/log" @@ -56,7 +55,7 @@ const ( // PER TEST rather than per suite, so that the do function can be set on a test by test (or even more granular) // basis. func NewTestTransportController(state *state.State, client pub.HttpClient) transport.Controller { - return transport.NewController(state, NewTestFederatingDB(state), &federation.Clock{}, client) + return transport.NewController(state, NewTestFederatingDB(state), client) } type MockHTTPClient struct { -- cgit v1.3